public class TField extends TWidget
Modifier and Type | Field and Description |
---|---|
protected int |
backgroundChar
Background character for unfilled-in text.
|
protected TAction |
enterAction
The action to perform when the user presses enter.
|
protected boolean |
fixed
If true, only allow enough characters that will fit in the width.
|
protected boolean |
insertMode
If true, new characters are inserted at position.
|
protected TMouseEvent |
mouse
Remember mouse state.
|
protected int |
position
Current editing position within text.
|
protected int |
screenPosition
Current editing position screen column number.
|
protected java.lang.String |
text
Field text.
|
protected TAction |
updateAction
The action to perform when the text is updated.
|
protected int |
windowStart
Beginning of visible portion.
|
Constructor and Description |
---|
TField(TWidget parent,
int x,
int y,
int width,
boolean fixed)
Public constructor.
|
TField(TWidget parent,
int x,
int y,
int width,
boolean fixed,
java.lang.String text)
Public constructor.
|
TField(TWidget parent,
int x,
int y,
int width,
boolean fixed,
java.lang.String text,
TAction enterAction,
TAction updateAction)
Public constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
appendChar(int ch)
Append char to the end of the field.
|
protected void |
dispatch(boolean enter)
Dispatch to the action function.
|
void |
draw()
Draw the text field.
|
void |
end()
Set the editing position to the last filled character.
|
int |
getBackgroundChar()
Get field background character.
|
java.lang.String |
getText()
Get field text.
|
void |
home()
Position the cursor at the first column.
|
protected void |
insertChar(int ch)
Insert char somewhere in the middle of the field.
|
protected boolean |
mouseOnField()
Returns true if the mouse is currently on the field.
|
protected void |
normalizeWindowStart()
Normalize windowStart such that most of the field data if visible.
|
void |
onKeypress(TKeypressEvent keypress)
Handle keystrokes.
|
void |
onMouseDown(TMouseEvent mouse)
Handle mouse button presses.
|
protected int |
screenToTextPosition(int screenPosition)
Determine string position from screen position.
|
void |
setActiveColorKey(java.lang.String activeColorKey)
Set the active color key.
|
void |
setBackgroundChar(int backgroundChar)
Set field background character.
|
void |
setEnterAction(TAction action)
Set the action to perform when the user presses enter.
|
void |
setHeight(int height)
Override TWidget's height: we can only set height at construction
time.
|
void |
setInactiveColorKey(java.lang.String inactiveColorKey)
Set the inactive color key.
|
void |
setPosition(int position)
Set the editing position.
|
void |
setText(java.lang.String text)
Set field text.
|
void |
setUpdateAction(TAction action)
Set the action to perform when the field is updated.
|
protected void |
updateCursor()
Update the visible cursor position to match the location of position
and windowStart.
|
activate, activate, activate, activateAll, addButton, addCalendar, addCheckBox, addComboBox, addDirectoryList, addDirectoryList, addDirectoryList, addDirectoryList, addEditor, addField, addField, addField, addImage, addImage, addLabel, addLabel, addLabel, addLabel, addLabel, addLabel, addList, addList, addList, addList, addPanel, addPasswordField, addPasswordField, addPasswordField, addProgressBar, addRadioGroup, addSpinner, addSplitPane, addTable, addTable, addText, addText, addTreeViewWidget, addTreeViewWidget, close, compareTo, doRepaint, drawBox, drawBox, drawBoxShadow, fileOpenBox, fileOpenBox, fileOpenBox, fileOpenBox, fileSaveBox, getAbsoluteX, getAbsoluteY, getActiveChild, getApplication, getAttrXY, getChildren, getCursorAbsoluteX, getCursorAbsoluteY, getCursorX, getCursorY, getHeight, getLayoutManager, getParent, getScreen, getTheme, getWidth, getWindow, getX, getY, handleEvent, hLineXY, inputBox, inputBox, inputBox, isAbsoluteActive, isActive, isCursorVisible, isDrawable, isEnabled, isVisible, messageBox, messageBox, mouseWouldHit, onCommand, onIdle, onMenu, onMouseDoubleClick, onMouseMotion, onMouseUp, onResize, putAll, putAttrXY, putAttrXY, putCharXY, putCharXY, putCharXY, putStringXY, putStringXY, remove, remove, remove, remove, removeAll, resetTabOrder, setActive, setCursorVisible, setCursorX, setCursorY, setDimensions, setEnabled, setLayoutManager, setParent, setupForTWindow, setVisible, setWidth, setWindow, setX, setY, splitHorizontal, splitVertical, switchWidget, toPrettyString, toPrettyString, toString, vLineXY
protected int backgroundChar
protected java.lang.String text
protected boolean fixed
protected int position
protected int screenPosition
protected int windowStart
protected boolean insertMode
protected TMouseEvent mouse
protected TAction enterAction
protected TAction updateAction
public TField(TWidget parent, int x, int y, int width, boolean fixed)
parent
- parent widgetx
- column relative to parenty
- row relative to parentwidth
- visible text widthfixed
- if true, the text cannot exceed the display widthpublic TField(TWidget parent, int x, int y, int width, boolean fixed, java.lang.String text)
parent
- parent widgetx
- column relative to parenty
- row relative to parentwidth
- visible text widthfixed
- if true, the text cannot exceed the display widthtext
- initial text, default is empty stringpublic TField(TWidget parent, int x, int y, int width, boolean fixed, java.lang.String text, TAction enterAction, TAction updateAction)
parent
- parent widgetx
- column relative to parenty
- row relative to parentwidth
- visible text widthfixed
- if true, the text cannot exceed the display widthtext
- initial text, default is empty stringenterAction
- function to call when enter key is pressedupdateAction
- function to call when the text is updatedprotected boolean mouseOnField()
public void onMouseDown(TMouseEvent mouse)
onMouseDown
in class TWidget
mouse
- mouse button eventpublic void onKeypress(TKeypressEvent keypress)
onKeypress
in class TWidget
keypress
- keystroke eventpublic void setHeight(int height)
public final int getBackgroundChar()
public void setBackgroundChar(int backgroundChar)
backgroundChar
- the background characterpublic final java.lang.String getText()
public void setText(java.lang.String text)
text
- the new field textprotected void dispatch(boolean enter)
enter
- if true, the user pressed Enter, else this was an update
to the text.protected int screenToTextPosition(int screenPosition)
screenPosition
- the position on screenprotected void updateCursor()
protected void normalizeWindowStart()
protected void appendChar(int ch)
ch
- char to appendprotected void insertChar(int ch)
ch
- char to appendpublic void home()
public void end()
public void setPosition(int position)
position
- the new positionjava.lang.IndexOutOfBoundsException
- if position is outside the range of
the available textpublic void setActiveColorKey(java.lang.String activeColorKey)
activeColorKey
- ColorTheme key color to use when this field is
activepublic void setInactiveColorKey(java.lang.String inactiveColorKey)
inactiveColorKey
- ColorTheme key color to use when this field is
inactivepublic void setEnterAction(TAction action)
action
- the action to perform when the user presses enterpublic void setUpdateAction(TAction action)
action
- the action to perform when the field is updatedCopyright © 2019 Kevin Lamonte. Licensed MIT.