Package snap.view
Class TextField
java.lang.Object
snap.props.PropObject
snap.view.View
snap.view.ParentView
snap.view.TextField
- All Implemented Interfaces:
PropChange.DoChange
,XMLArchiver.Archivable
A view subclass for editing a single line of text.
-
Nested Class Summary
Nested classes/interfaces inherited from class snap.view.View
View.Overflow
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class snap.view.ParentView
_children, Children_Prop, NeedsLayout_Prop
Fields inherited from class snap.view.View
_align, _border, _borderRadius, _effect, _fill, _font, _margin, _padding, _repaintRect, _showing, _spacing, _vertical, Action, Align_Prop, Border_Prop, BorderRadius_Prop, Cursor_Prop, Disabled_Prop, DragEvents, Effect_Prop, Fill_Prop, Focusable_Prop, Focused_Prop, FocusWhenPressed_Prop, Font_Prop, GrowHeight_Prop, GrowWidth_Prop, Height_Prop, KeyEvents, KeyPress, KeyRelease, KeyType, LeanX_Prop, LeanY_Prop, Managed_Prop, Margin_Prop, MaxHeight_Prop, MaxWidth_Prop, MinHeight_Prop, MinWidth_Prop, MouseDrag, MouseEnter, MouseEvents, MouseExit, MouseMove, MousePress, MouseRelease, Name_Prop, Opacity_Prop, Overflow_Prop, Padding_Prop, Paintable_Prop, Parent_Prop, Pickable_Prop, PrefHeight_Prop, PrefWidth_Prop, Rotate_Prop, RuntimeClassName_Prop, ScaleX_Prop, ScaleY_Prop, Scroll, Showing_Prop, Spacing_Prop, Text_Prop, TextColor_Prop, ToolTip_Prop, TransX_Prop, TransY_Prop, Vertical_Prop, Visible_Prop, Width_Prop, X_Prop, Y_Prop
Fields inherited from class snap.props.PropObject
_pcs, EMPTY_OBJECT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Called when escape key is pressed to cancels editing in TextField.protected void
fireActionEvent
(ViewEvent anEvent) Override to reset FocusedGainedVal.void
fromXMLView
(XMLArchiver anArchiver, XMLElement anElement) XML unarchival.int
Returns the column count.getLabel()
Returns the label in the background.protected double
getPrefHeightImpl
(double aW) Calculates the preferred height.protected double
getPrefWidthImpl
(double aH) Calculates the preferred width.Returns the prompt text.getPropValue
(String aPropName) Returns the value for given prop name.int
Returns the character index of the end of the text selection.int
Returns the character index of the start of the text selection.getText()
Returns the plain string of the text being edited.Returns the text color.Returns a mapped property name.protected void
Override to customize for this class.protected void
Override to support TextColor.boolean
isEdited()
Returns whether text has been edited since last focus (while focused).boolean
Returns whether text view fires action on focus lost (if text changed).boolean
Returns whether text field accepts multiple lines of text.boolean
Returns whether the selection is empty.protected void
keyPressed
(ViewEvent anEvent) Called when a key is pressed.protected void
Layout children.int
length()
Returns the number of characters in the text string.protected void
paintFront
(Painter aPntr) Paints TextField.protected void
Override to update font.protected void
processActionEvent
(ViewEvent anEvent) Called when action event is received.protected void
processEvent
(ViewEvent anEvent) Process event.void
replaceChars
(String aString) Replaces the current selection with the given string.void
Selects all the characters in the text editor.static void
setBackLabelAlignAnimatedOnFocused
(TextField aTextField, boolean aValue) Sets the given TextField to animate background label alignment from center to left when focused.void
setColCount
(int aValue) Sets the column count.void
setCompletionText
(String aString) Sets text that represents a completion of current text.protected void
setEdited
(boolean aValue) Sets whether text has been edited since last focus (while focused).void
setFireActionOnFocusLost
(boolean aValue) Sets whether text area sends action on focus lost (if text changed).protected void
setFocused
(boolean aValue) Override to track FocusGainedValue.void
Override to update font.void
setMultiline
(boolean aValue) Sets whether text field accepts multiple lines of text.void
setPromptText
(String aStr) Sets the prompt text.void
setPropValue
(String aPropName, Object aValue) Sets the value for given prop name.void
setSel
(int newStartEnd) Sets the character index of the text cursor.void
setSel
(int aStart, int anEnd) Sets the character index of the start and end of the text selection.void
Set text string of text editor.void
setTextColor
(Color aPaint) Sets the text color.toString()
Standard toString implementation.toXMLView
(XMLArchiver anArchiver) XML archival.Methods inherited from class snap.view.ParentView
addChild, addChild, addDeepChangeListener, childDidDeepChange, childDidPropChange, fromXML, fromXMLChildren, getChild, getChildAtXY, getChildCount, getChildCountManaged, getChildForClass, getChildForName, getChildLast, getChildren, getChildrenArray, getChildrenForClass, getChildrenInPaintOrder, getChildrenManaged, getFocusNext, getFocusPrev, getViewProxy, indexOfChild, intersectsShape, isInLayout, isNeedsLayout, isNeedsLayoutDeep, isNeedsRepaintDeep, layout, layoutDeep, layoutDeepImpl, layoutFloatingViews, paintAll, paintChildren, processPropChange, relayout, removeChild, removeChild, removeChildren, removeDeepChangeListener, setChildren, setNeedsLayout, setNeedsLayoutDeep, setNeedsRepaintDeep, setOwner, setOwnerChildren, setShowing, themeChanged, toXML, toXMLChildren
Methods inherited from class snap.view.View
addEventFilter, addEventHandler, clone, contains, contains, containsShape, createActionEvent, disableEvents, enableEvents, getAlign, getAlignX, getAlignY, getAnim, getAnimCleared, getAnimTimeDeep, getBestHeight, getBestSize, getBestWidth, getBorder, getBorderRadius, getBounds, getBoundsLocal, getBoundsParent, getBoundsShape, getBoundsShapeParent, getClip, getClipAll, getClipBounds, getClipBoundsAll, getCursor, getDefaultFont, getEffect, getEnv, getEventAdapter, getFill, getFillColor, getFocusNext, getFocusPrev, getFont, getHeight, getHost, getInsetsAll, getLean, getLeanX, getLeanY, getLocalToParent, getLocalToParent, getMargin, getMaxHeight, getMaxSize, getMaxWidth, getMaxX, getMaxY, getMidX, getMidY, getMinHeight, getMinHeightImpl, getMinSize, getMinWidth, getMinWidthImpl, getName, getOpacity, getOpacityAll, getOverflow, getOwner, getOwner, getPadding, getParent, getParent, getParentCount, getParentToLocal, getParentToLocal, getPhysics, getPhysics, getPrefHeight, getPrefHeight, getPrefSize, getPrefWidth, getPrefWidth, getProp, getPropDefault, getProps, getRepaintRect, getRepaintRectExpanded, getRootView, getRotate, getRuntimeClassName, getScale, getScaleX, getScaleY, getSize, getSpacing, getToolTip, getToolTip, getTransX, getTransY, getUpdater, getVisibleBounds, getWidth, getWindow, getX, getXY, getY, indexInHost, indexInParent, isActionable, isAncestor, isAnimActive, isClipToBounds, isDisabled, isEnabled, isFocusable, isFocused, isFocusKeysEnabled, isFocusPainted, isFocusWhenPressed, isFontSet, isGrowHeight, isGrowWidth, isGuest, isHorizontal, isLocalToParentSimple, isManaged, isManagedVisible, isMaxHeightSet, isMaxWidthSet, isMinHeightSet, isMinWidthSet, isMouseDown, isMouseOver, isNeedsRepaint, isPaintable, isPickable, isPickableVisible, isPrefHeightSet, isPrefWidthSet, isPropDefault, isShowing, isToolTipEnabled, isVertical, isVisible, localToParent, localToParent, localToParent, localToParent, localToScreen, paintAbove, paintBack, parentToLocal, parentToLocal, parentToLocal, parentToLocal, playAnimDeep, processEventAll, processEventFilters, processEventHandlers, relayoutParent, removeEventFilter, removeEventHandler, repaint, repaint, repaint, repaintInParent, requestFocus, runDelayed, runIntervals, runLater, scrollToVisible, setActionable, setAlign, setAlignX, setAlignY, setAnimString, setAnimTimeDeep, setBorder, setBorder, setBorderRadius, setBounds, setBounds, setBoundsLocal, setClipToBounds, setCursor, setDisabled, setEffect, setEnabled, setFill, setFocusable, setFocusKeysEnabled, setFocusPainted, setFocusWhenPressed, setGrowHeight, setGrowWidth, setHeight, setLean, setLeanX, setLeanY, setManaged, setMargin, setMargin, setMaxHeight, setMaxSize, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinSize, setMinWidth, setName, setOpacity, setOverflow, setPadding, setPadding, setPaintable, setParent, setPickable, setPrefHeight, setPrefSize, setPrefSize, setPrefWidth, setProp, setRotate, setRuntimeClassName, setScale, setScaleX, setScaleY, setSize, setSize, setSizeLocal, setSizeToBestSize, setSizeToPrefSize, setSpacing, setToolTip, setToolTipEnabled, setTransX, setTransY, setVertical, setVisible, setWidth, setX, setXY, setXYLocal, setY, stopAnimDeep, stopIntervals, toStringProps
Methods inherited from class snap.props.PropObject
addPropChangeListener, addPropChangeListener, firePropChange, firePropChange, firePropChange, getPropForName, getPropParent, getPropSet, getPropsForArchival, getPropsForArchivalExtra, getPropsString, processArchivedNode, processUnarchivedNode, removePropChangeListener, removePropChangeListener, setPropsString, setPropValues
-
Field Details
-
_focusGainedText
-
ColCount_Prop
- See Also:
-
PromptText_Prop
- See Also:
-
Multiline_Prop
- See Also:
-
FireActionOnFocusLost_Prop
- See Also:
-
Selection_Prop
- See Also:
-
Edited_Prop
- See Also:
-
-
Constructor Details
-
TextField
public TextField()Constructor.
-
-
Method Details
-
initStyleProps
protected void initStyleProps()Override to support TextColor.- Overrides:
initStyleProps
in classView
-
getTextColor
Returns the text color.- Overrides:
getTextColor
in classView
-
setTextColor
Sets the text color.- Overrides:
setTextColor
in classView
-
getColCount
public int getColCount()Returns the column count. -
setColCount
public void setColCount(int aValue) Sets the column count. -
getPromptText
Returns the prompt text. -
setPromptText
Sets the prompt text. -
isFireActionOnFocusLost
public boolean isFireActionOnFocusLost()Returns whether text view fires action on focus lost (if text changed). -
setFireActionOnFocusLost
public void setFireActionOnFocusLost(boolean aValue) Sets whether text area sends action on focus lost (if text changed). -
isMultiline
public boolean isMultiline()Returns whether text field accepts multiple lines of text. -
setMultiline
public void setMultiline(boolean aValue) Sets whether text field accepts multiple lines of text. -
getLabel
Returns the label in the background. -
setFocused
protected void setFocused(boolean aValue) Override to track FocusGainedValue.- Overrides:
setFocused
in classView
-
fireActionEvent
Override to reset FocusedGainedVal.- Overrides:
fireActionEvent
in classView
-
isEdited
public boolean isEdited()Returns whether text has been edited since last focus (while focused). -
setEdited
protected void setEdited(boolean aValue) Sets whether text has been edited since last focus (while focused). -
length
public int length()Returns the number of characters in the text string. -
getText
Returns the plain string of the text being edited. -
setText
Set text string of text editor. -
getSelStart
public int getSelStart()Returns the character index of the start of the text selection. -
getSelEnd
public int getSelEnd()Returns the character index of the end of the text selection. -
isSelEmpty
public boolean isSelEmpty()Returns whether the selection is empty. -
setSel
public void setSel(int newStartEnd) Sets the character index of the text cursor. -
setSel
public void setSel(int aStart, int anEnd) Sets the character index of the start and end of the text selection. -
selectAll
public void selectAll()Selects all the characters in the text editor. -
replaceChars
Replaces the current selection with the given string. -
setCompletionText
Sets text that represents a completion of current text. This preserves the capitalization of chars in the current text and sets the selection to the remainder. If next key press is delete, removes the added remainder. -
paintFront
Paints TextField.- Overrides:
paintFront
in classView
-
getPrefWidthImpl
protected double getPrefWidthImpl(double aH) Calculates the preferred width.- Overrides:
getPrefWidthImpl
in classView
-
getPrefHeightImpl
protected double getPrefHeightImpl(double aW) Calculates the preferred height.- Overrides:
getPrefHeightImpl
in classView
-
layoutImpl
protected void layoutImpl()Layout children.- Overrides:
layoutImpl
in classParentView
-
processEvent
Process event.- Overrides:
processEvent
in classView
-
keyPressed
Called when a key is pressed. -
processActionEvent
Called when action event is received. -
escape
Called when escape key is pressed to cancels editing in TextField. First cancel resets focus gained value. Second hands focus to previous view. -
setFont
Override to update font.- Overrides:
setFont
in classParentView
-
parentFontChanged
protected void parentFontChanged()Override to update font.- Overrides:
parentFontChanged
in classParentView
-
getValuePropName
Returns a mapped property name.- Overrides:
getValuePropName
in classView
-
initProps
Override to customize for this class.- Overrides:
initProps
in classParentView
-
getPropValue
Returns the value for given prop name.- Overrides:
getPropValue
in classParentView
-
setPropValue
Sets the value for given prop name.- Overrides:
setPropValue
in classParentView
-
toString
Standard toString implementation.- Overrides:
toString
in classPropObject
-
toXMLView
XML archival.- Overrides:
toXMLView
in classParentView
-
fromXMLView
XML unarchival.- Overrides:
fromXMLView
in classParentView
-
setBackLabelAlignAnimatedOnFocused
Sets the given TextField to animate background label alignment from center to left when focused.
-