# Class: TextField

### LuxModule: gui

A textfield element for usertextinput. Textfields have following skinsurfaces:

1. textfield
2. textfield_hover
3. textfield_focus
4. textfield_disabled

## Hierarchy

    o-+ Component
      o-+ TextField

## Methods:

### Method overview:

- TEXTFIELD_ALIGNCENTERED
- TEXTFIELD_ALIGNLEFT
- TEXTFIELD_ALIGNRIGHT
- copyText
- createVisibles
- cutText
- deleteVisibles
- getCursorCaretPosAtX
- getText
- getTextLength
- hideVisibles
- insertText
- isFocusable
- mousePressed
- mouseReleased
- new
- onAction
- onKeyTyped
- onTextChanged
- pasteText
- positionUpdate
- replaceText
- setCursorCaretPosAtX
- setText
- showVisibles
- toString

new (class, int x,y,w,h, align)
  returns: (TextField)
  creates a textfield with the given dimensions. The align value can be a constant from the TextField table (TEXTFIELD_ALIGNRIGHT, ...).
TEXTFIELD_ALIGNCENTERED
  [int] - constant for centered text alignment
TEXTFIELD_ALIGNLEFT
  [int] - constant for left text alignment
TEXTFIELD_ALIGNRIGHT
  [int] - constant for right text alignment
copyText (TextField)
  returns: ()
  Copy selected text in textfield into clipboard.
createVisibles (Component self,l2dnode basel2d)
  returns: ()

  description from overloaded method of Component:

  called when a Component is now displayable (doesn't have to be visible)
cutText (TextField)
  returns: ()
  Cut selected text in textfield into clipboard, deleting the selected text.
deleteVisibles (Component self)
  returns: ()

  description from overloaded method of Component:

  called when a Component is no longer displayed
getCursorCaretPosAtX (TextField,x)
  returns: (x)
  converts relative pixel coordinate in caret position
getText (TextField,[from,[to] ])
  returns: (string)
  returns the text of the textfield, if bounds are given it returns the text within that range
getTextLength (TextField)
  returns: (int length)
  returns number of chars
hideVisibles (Component self)
  returns: ()

  description from overloaded method of Component:

  called when visible objects (l2ds) are no longer visible
insertText (TextField, string tx, int at)
  returns: (int)
  inserts the text at the specified index. Returns the index at which the insertion stoped.
isFocusable (TextField)
  returns: (boolean)
  returns true if visible
mousePressed (Component self, MouseEvent e, boolean mouseover)
  returns: ()

  description from overloaded method of Component:

  called if the mouse was pressed on the component. If mouseover is true, the mouse is actually on THIS component and not on one of its childs, which will create events too.
mouseReleased (Component self, MouseEvent e, boolean mouseover)
  returns: ()

  description from overloaded method of Component:

  called if the mouse was released on the component
onAction (TextField, String text)
  returns: ()
  called if the user pressed enter. Overload this to react on this
onKeyTyped (TextField, KeyEvent)
  returns: ()
  called if a key was typed on the textfield.
onTextChanged (TextField)
  returns: ()
  called if the text changed (ie. by user input).
pasteText (TextField)
  returns: ()
  paste text from clipboard in textfield and overwrite the selection
positionUpdate (Component self,int zindex,Rectangle clip)
  returns: (int newz)

  description from overloaded method of Component:

  called when the component was moved or resized. Overload this method for visual appearance. The zindex is the id to use for zordering the components. Return the newz value, reserving all the values that you require for your visual nodes.
replaceText (TextField)
  returns: (boolean)
  returns true if visible
setCursorCaretPosAtX (TextField,x,boolean ignoreselectionstartset)
  returns: ()
  sets caret position to local pixel coordinate. If a third argument is passed and is true, the selectionstart is not repositioned.
setText (TextField,string,[boolean donnotfireevent])
  returns: ()
  sets text of the textfield, causes onTextChanged call. If donnotfireevent is true, the onTextChanged function is not called.
showVisibles (Component self)
  returns: ()

  description from overloaded method of Component:

  called when visible objects (l2ds) are now visible
toString (TextField)
  returns: (string)
  returns simple component representation

## Inherited Methods:

### From Component

acceptSkinBounds, addKeyListener, addMouseListener, addTooltipListener, clipinsets, colors, contains, createVisibles, delete, deleteVisibles, fadeTo, focus, focuscolors, getBottom, getBounds, getClipRect, getFocusComponentAt, getFocusElement, getFocusIndex, getHeight, getLocation, getMinSize, getMouseLock, getParent, getRight, getSize, getSkin, getTooltip, getWidth, getX, getY, hasFocus, hideVisibles, index, invalidate, isClipped, isDisplayedFlag, isFocusable, isMouseLocker, isVisible, isVisibleFlag, keyEvent, keylisteners, local2world, lockMouse, mouseClicked, mouseEntered, mouseEvent, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheeled, mouselisteners, moveToRect, new, newFocusOrder, onDestroy, onDisplayChange, onGainedFocus, onLostFocus, onVisibilityChange, positionUpdate, remove, removeKeyListener, removeMouseListener, removeTooltipListener, setBounds, setClip, setColor, setDisabled, setDisplayable, setFont, setLocation, setSize, setSkin, setTooltip, setVisibility, showTooltipInformation, showVisibles, skinnames.defaultskin, skinnames.focusedskin, skinnames.hoveredskin, skinnames.pressedskin, think, toString, transferFocus, transferFocusOnArrows, transferFocusOnTab, unlockMouse, updateSkin, validate, validateFocus, white, world2local, zorderoffset