Class zebkit.ui.TextField
extends <zebkit.ui.Label>
<zebkit.ui>

Text field UI component. The component is designed to enter single line, multi lines or password text. The component implement text field functionality from the scratch. It supports the following features

  • Text selection
  • Redu/Undo actions
  • Native WEB clipboard
  • Basic text navigation
  • Read-only mode
  • Left or right text alignment
Constructor:
zebkit.ui.TextField ([txt], [maxCol])

Parameters:
  • [txt] <String | zebkit.data.TextModel | zebkit.draw.TextRender>

    a text the text field component has to be filled. The parameter can be a simple string, text model or text render class instance.

  • [maxCol] <Integer>

    a maximal size of entered text. -1 means the size of the edited text has no length limit.




public void clearSelection ( )
public <String> cut ( )
protected void drawCursor (g)
protected <Object> findNextWord (t, line, col, d)
public <Array> getEndSelection ( )
public <String> getSelectedText ( )
public <Array> getStartSelection ( )
public <Object> getTextRowColAt (x, y)
public <Boolean> hasSelection ( )
protected <Boolean> isFiltered (e)
public void redo ( )
public void remove (pos, size)
public void removeSelected ( )
protected void repaintCursor ( )
public void select (startOffset, endOffset)
public void selectAll ( )
public void setBlinking ([period])
public void setCursorSize (w, h)
public void setCursorView (v)
public void setCursorWidth (w)
public void setEditable (b)
public void setHint (hint)
public void setPosition (p)
public void setPSByRowsCols (r, c)
public void setSelectView (c)
public void setTextAlignment (a)
public void setValue (s)
public void shortcutFired (e)
protected void startSelection ( )
public void undo ( )
public <Boolean> write (pos, s)


Inherited methods:
$setConstraints(c)    add(constr, d)    byConstraints([p], c)    byPath(path, [cb])    calcPreferredSize(t)    doLayout( )    fire(event, [path], [params])    focused( )    getBottom( )    getCanvas( )    getColor( )    getComponentAt(x, y)    getFont( )    getHorPadding( )    getLeft( )    getModel( )    getPreferredSize( )    getRight( )    getTop( )    getValue( )    getVerPadding( )    hasFocus( )    indexOf(c)    insert(i, constr, d)    invalidate( )    invalidateLayout( )    kidAdded(index, constr, l)    kidRemoved(i, l)    laidout( )    load(JSON)    off([eventName], [path], [cb])    on([eventName], [path], cb)    paintComponent(g)    paintViewAt(g, ax, ay, v)    properties([path], props)    property([path], name, value)    recalc( )    relocated(px, py)    removeAll( )    removeAt(i)    removeByConstraints(ctr)    removeMe([after])    repaint([x], [y], [w], [h])    requestFocus( )    requestFocusIn([timeout])    resized(pw, ph)    setAt(i, d)    setBackground(v)    setBorder([v])    setBottomPadding(bottom)    setBounds(x, y, w, h)    setByConstraints(constr, c)    setColor(c)    setConstraints(ctr)    setEnabled(b)    setFont(f)    setId(id)    setKids(a)    setLayout(m)    setLeftPadding(left)    setLocation(xx, yy)    setModel(m)    setPadding(v)    setParent(o)    setPreferredSize(w, h)    setProperties([path], props)    setRightPadding(right)    setSize(w, h)    setTopPadding(top)    setView(v)    setVisible(b)    toBack( )    toFront( )    toPreferredHeight( )    toPreferredSize( )    toPreferredWidth( )    toView(target)    validate( )    validateMetric( )    vrp( )   


public chainable clearSelection ( )

Clear a text selection.

public <String> cut ( )

Cut selected text


Returns: <String>

a text that has been selected and cut

protected void drawCursor (g)

Draw the text field cursor.


Parameters:
protected <Object> findNextWord (t, line, col, d)

Find the next or previous word in the given text model starting from the given line and column.


Parameters:
Returns: <Object>

a structure with the next or previous word location:

   { row: {Integer}, col: {Integer} }

The method returns null if the next or previous word cannot be found.

public <Array> getEndSelection ( )

Get an ending position (row and column) of a selected text


Returns: <Array>

a position of a selected text. First element of is a row and second column of selected text. null if there is no any selected text

public <String> getSelectedText ( )

Get a selected text


Returns: <String>

a selected text

public <Array> getStartSelection ( )

Get a starting position (row and column) of a selected text


Returns: <Array>

a position of a selected text. First element of is a row and second column of selected text. null if there is no any selected text

public <Object> getTextRowColAt (x, y)

Compute a text column and row by the given location.


Parameters:
  • x <Integer>

    a x coordinate

  • y <Integer>

    a y coordinate


Returns: <Object>

a text row and column as an object { row:, col }.

public <Boolean> hasSelection ( )

Tests if the text field has a selected text


Returns: <Boolean>

true if the text field has a selected text

protected <Boolean> isFiltered (e)

Test if the given key pressed event has to be processed


Parameters:
Returns: <Boolean>

true if the given key pressed event doesn't have be processed

public chainable redo ( )

Performs redo operation

@Override zebkit.layout.Layoutable
public void remove (pos, size)

Remove the specified part of edited text


Parameters:
  • pos <Integer>

    a start position of a removed text

  • size <Integer>

    a size of removed text

public chainable removeSelected ( )

Remove selected text

protected void repaintCursor ( )

Force text field cursor repainting.

public chainable select (startOffset, endOffset)

Select the specified part of the edited text


Parameters:
  • startOffset <Integer>

    a start position of a selected text

  • endOffset <Integer>

    an end position of a selected text

public chainable selectAll ( )

Select all text.

public chainable setBlinking ([period])

Set the specified blinking period of the text field cursor


Parameters:
  • [period] <Integer>

    a text field cursor blinking period (in milliseconds), use -1 to disable cursor blinking. If the argument is not passed the default (500ms) blinking period will be applied.

public chainable setCursorSize (w, h)

Set cursor size.


Parameters:
  • w <Integer>

    a cursor width

  • h <Integer>

    a cursor height

public chainable setCursorView (v)

Set the cursor view. The view defines rendering of the text field cursor.


Parameters:
public chainable setCursorWidth (w)

Set cursor width.


Parameters:
  • w <Integer>

    a cursor width

public chainable setEditable (b)

Control the text field editable state


Parameters:
  • b <Boolean>

    true to make the text field editable

public chainable setHint (hint)

Set the specified hint text to be drawn with the given font and color. The hint is not-editable text that is shown in empty text field to help a user to understand which input the text field expects.


Parameters:
public chainable setPosition (p)

Set the specified cursor position controller


Parameters:
public chainable setPSByRowsCols (r, c)

Adjust the size of the text field component to be enough to place the given number of rows and columns.


Parameters:
  • r <Integer>

    a row of the text the height of the text field has to be adjusted

  • c <Integer>

    a column of the text the width of the text field has to be adjusted

public chainable setSelectView (c)

Set selection color or view


Parameters:
public chainable setTextAlignment (a)

Set the text algnment.


Parameters:
  • a <String>

    a text alignment. Use "left" or "right" as the parameter value

@Override zebkit.ui.Label
public chainable setValue (s)

Set the text content of the text field component


Parameters:
  • s <String>

    a text the text field component has to be filled

public void shortcutFired (e)

Shortcut event handler


Parameters:
  • e <java.ui.event.ShortcutEvent>

    a shortcut event

protected chainable startSelection ( )

Start selection.

public chainable undo ( )

Performs undo operation

public <Boolean> write (pos, s)

Insert the specified text into the edited text at the given position


Parameters:
  • pos <Integer>

    a start position of a removed text

  • s <String>

    a text to be inserted


Returns: <Boolean>

true if repaint has been requested



Inherited attributes:
public zebkit.draw.View bg    public zebkit.draw.View border    public Boolean canHaveFocus    public Object constraints    public Integer height    public Boolean isEnabled    public Boolean isValid    public Boolean isVisible    public Array kids    public zebkit.layout.Layout layout    public zebkit.layout.Layoutable parent    public zebkit.draw.View view    public Integer width    public Integer x    public Integer y   



public <Number> blinkigPeriod

Specify the text field cursor blinking period in milliseconds. -1 means no blinkable cursor

public <Integer> cursorHeight

Cursor height

public <String> cursorType

Cursor type

public <zebkit.draw.View> cursorView

Cursor view

public <Integer> cursorWidth

Cursor width

public <Integer> cursorX

Cursor x loacation

public <Integer> cursorY

Cursor y loacation

public <zebkit.draw.View> hint

Hint view

public <Boolean> isEditable

Indicate if the text field is editable

public <zebkit.util.Position> position

Cursor position manager

public <zebkit.draw.View | String> selectView

Selection view.

public <String> textAlign

Text alignment