Package snap.view
Class TextArea
java.lang.Object
snap.props.PropObject
snap.view.View
snap.view.ParentView
snap.view.TextArea
- All Implemented Interfaces:
PropChange.DoChange
,XMLArchiver.Archivable
- Direct Known Subclasses:
DevPaneConsoleTextArea
,TextView
A view subclass for displaying and editing a TextBlock.
-
Nested Class Summary
Nested classes/interfaces inherited from class snap.view.View
View.Overflow
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static boolean
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
addChars
(CharSequence theChars) Adds the given chars to end of text.void
addChars
(CharSequence theChars, int charIndex) Adds the given chars at given char index.void
addCharsWithStyle
(CharSequence theChars, TextStyle textStyle) Adds the given chars with given style to text end.void
addCharsWithStyle
(CharSequence theChars, TextStyle textStyle, int charIndex) Adds the given chars with given style to text at given index.void
addCharsWithStyleString
(CharSequence theChars, String styleString) Adds the given chars to text with given style string.char
charAt
(int anIndex) Returns the individual character at given index.void
clear()
Clears the text.void
copy()
Copies the current selection onto the clipboard.protected TextAdapter
createTextAdapter
(TextBlock textBlock) Override to create TextAreaKeys.void
cut()
Copies the current selection onto the clip board, then deletes the current selection.void
delete()
Deletes the current selection.fromXML
(XMLArchiver anArchiver, XMLElement anElement) XML unarchival.int
getCharIndexForXY
(double anX, double aY) Returns the char index for given point in text coordinate space.protected Object
getClipboardContent
(Clipboard clipboard) Returns the clipboard content.Returns the default line style for text.Returns the default text style for text.double
Returns the font scale of the text box.Returns the format of the current selection or cursor.getLine
(int anIndex) Returns the individual line at given index.int
Returns the number of lines.getLineForCharIndex
(int anIndex) Returns the line for the given character index.protected double
getPrefHeightImpl
(double aW) Returns the height needed to display all characters.protected double
getPrefWidthImpl
(double aH) Returns the width needed to display all characters.getPropValue
(String aPropName) Override to support properties for this class.getSel()
Returns the text selection.int
Returns the character index of the end of the text selection.int
Returns the final character index of the selection (usually SelEnd).int
Returns the character index of the start of the text selection.Returns the root text block.getText()
Returns the plain string of the text being edited.Returns the text adapter.Returns the text block that holds the text.Returns the color of the current selection or cursor.Returns the font of the text block.getTokenForCharIndex
(int anIndex) Returns the token for given character index.Returns the undoer.Returns a mapped property name.protected void
Called when SourceText changes (chars added, updated or deleted).protected void
Called when TextAdapter has prop change.protected void
Override to support properties for this class.boolean
Returns whether Text shape is editable.static boolean
Returns whether layout tries to hyphenate wrapped words.boolean
Returns whether text supports multiple styles.boolean
Returns whether the selection is empty.boolean
Returns whether editor is doing check-as-you-type spelling.boolean
Returns whether to synchronize text area font with text block.boolean
Returns whether TextView is underlined.boolean
Returns whether undo is activated.boolean
Returns whether to wrap lines that overrun bounds.protected void
keyPressed
(ViewEvent anEvent) Called when a key is pressed.protected void
keyReleased
(ViewEvent anEvent) Called when a key is released.protected void
Called when a key is typed.int
length()
Returns the number of characters in the text string.protected void
mouseDragged
(ViewEvent anEvent) Handles mouse dragged.protected void
mouseMoved
(ViewEvent anEvent) Handle MouseMoved.protected void
mousePressed
(ViewEvent anEvent) Handles mouse pressed.protected void
mouseReleased
(ViewEvent anEvent) Handles mouse released.protected void
paintFront
(Painter aPntr) Paint text.protected void
Override to update font.void
paste()
Pasts the current clipboard data over the current selection.protected void
processActionEvent
(ViewEvent anEvent) Called when action event is received.void
processEvent
(ViewEvent anEvent) Process event.void
redo()
Called to redo the last text change.void
removeChars
(int aStart, int anEnd) Deletes the given range of chars.void
replaceChars
(CharSequence theChars) Replaces the current selection with the given string.void
replaceChars
(CharSequence theChars, int startCharIndex, int endCharIndex) Replaces the current selection with the given string.void
replaceCharsWithContent
(Object theContent) Replaces the current selection with the given contents (TextBlock or String).void
replaceCharsWithStyle
(CharSequence theChars, TextStyle textStyle, int aStart, int anEnd) Replaces the current selection with the given string.void
Scales font sizes of all text in TextBox to fit in bounds by finding/setting FontScale.void
Selects all the characters in the text editor.void
setDefaultLineStyle
(TextLineStyle aLineStyle) Sets the default line style.void
setDefaultTextStyle
(TextStyle textStyle) Sets the default text style for text.void
setDefaultTextStyleString
(String styleString) Sets default text style for given style string.void
setEditable
(boolean aValue) Sets whether Text shape is editable.void
Sets the font of the current selection or cursor.void
setFontScale
(double aValue) Sets the font scale of the text box.void
setFormat
(TextFormat aFormat) Sets the format of the current selection or cursor, after trying to expand the selection to encompass currently selected, @-sign delineated key.static void
setHyphenating
(boolean aValue) Sets whether layout tries to hyphenate wrapped words.void
setPropValue
(String aPropName, Object aValue) Override to support properties for this class.void
setRichText
(boolean aValue) Sets whether text supports multiple styles.void
setSel
(int newStartEnd) Sets the character index of the text cursor.void
setSel
(int aStart, int aEnd) Sets the character index of the start and end of the text selection.void
setSourceText
(TextBlock aTextBlock) Sets the source TextBlock.void
setSyncTextFont
(boolean aValue) Sets whether to synchronize text area font with text block.void
Set text string of text editor.void
setTextColor
(Color aColor) Sets the color of the current selection or cursor.void
setTextFont
(Font aFont) Sets the font of the text block.void
setUnderlined
(boolean aValue) Sets whether TextView is underlined.void
setUndoActivated
(boolean aValue) Called to activate undo.void
setWrapLines
(boolean aValue) Sets whether to wrap lines that overrun bounds.toString()
Standard toString implementation.toXML
(XMLArchiver anArchiver) XML archival.void
undo()
Called to undo the last text change.Methods inherited from class snap.view.ParentView
addChild, addChild, addDeepChangeListener, childDidDeepChange, childDidPropChange, fromXMLChildren, fromXMLView, 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, layoutImpl, paintAll, paintChildren, processPropChange, relayout, removeChild, removeChild, removeChildren, removeDeepChangeListener, setChildren, setNeedsLayout, setNeedsLayoutDeep, setNeedsRepaintDeep, setOwner, setOwnerChildren, setShowing, themeChanged, toXMLChildren, toXMLView
Methods inherited from class snap.view.View
addEventFilter, addEventHandler, clone, contains, contains, containsShape, createActionEvent, disableEvents, enableEvents, fireActionEvent, 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, initStyleProps, 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, setFocused, 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
-
isSpellChecking
public static boolean isSpellChecking -
RichText_Prop
- See Also:
-
Editable_Prop
- See Also:
-
WrapLines_Prop
- See Also:
-
SourceText_Prop
- See Also:
-
Selection_Prop
- See Also:
-
-
Constructor Details
-
TextArea
public TextArea()Constructor. -
TextArea
public TextArea(boolean isRichText) Constructor with option for RichText. -
TextArea
Constructor for source text block.
-
-
Method Details
-
getTextAdapter
Returns the text adapter. -
createTextAdapter
Override to create TextAreaKeys. -
getTextBlock
Returns the text block that holds the text. -
getSourceText
Returns the root text block. -
setSourceText
Sets the source TextBlock. -
getText
Returns the plain string of the text being edited. -
setText
Set text string of text editor. -
isEditable
public boolean isEditable()Returns whether Text shape is editable. -
setEditable
public void setEditable(boolean aValue) Sets whether Text shape is editable. -
isWrapLines
public boolean isWrapLines()Returns whether to wrap lines that overrun bounds. -
setWrapLines
public void setWrapLines(boolean aValue) Sets whether to wrap lines that overrun bounds. -
isUndoActivated
public boolean isUndoActivated()Returns whether undo is activated. -
setUndoActivated
public void setUndoActivated(boolean aValue) Called to activate undo. -
isSyncTextFont
public boolean isSyncTextFont()Returns whether to synchronize text area font with text block. -
setSyncTextFont
public void setSyncTextFont(boolean aValue) Sets whether to synchronize text area font with text block. -
isSpellChecking
public boolean isSpellChecking()Returns whether editor is doing check-as-you-type spelling. -
isRichText
public boolean isRichText()Returns whether text supports multiple styles. -
setRichText
public void setRichText(boolean aValue) Sets whether text supports multiple styles. -
getDefaultTextStyle
Returns the default text style for text. -
setDefaultTextStyle
Sets the default text style for text. -
setDefaultTextStyleString
Sets default text style for given style string. -
getDefaultLineStyle
Returns the default line style for text. -
setDefaultLineStyle
Sets the default line style. -
length
public int length()Returns the number of characters in the text string. -
charAt
public char charAt(int anIndex) Returns the individual character at given index. -
isSelEmpty
public boolean isSelEmpty()Returns whether the selection is empty. -
getSelIndex
public int getSelIndex()Returns the final character index of the selection (usually SelEnd). -
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. -
getSel
Returns the text selection. -
setSel
public void setSel(int newStartEnd) Sets the character index of the text cursor. -
setSel
public void setSel(int aStart, int aEnd) 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. -
getTextFont
Returns the font of the text block. -
setTextFont
Sets the font of the text block. -
getTextColor
Returns the color of the current selection or cursor.- Overrides:
getTextColor
in classView
-
setTextColor
Sets the color of the current selection or cursor.- Overrides:
setTextColor
in classView
-
getFormat
Returns the format of the current selection or cursor. -
setFormat
Sets the format of the current selection or cursor, after trying to expand the selection to encompass currently selected, @-sign delineated key. -
isUnderlined
public boolean isUnderlined()Returns whether TextView is underlined. -
setUnderlined
public void setUnderlined(boolean aValue) Sets whether TextView is underlined. -
addChars
Adds the given chars to end of text. -
addChars
Adds the given chars at given char index. -
addCharsWithStyle
Adds the given chars with given style to text end. -
addCharsWithStyle
Adds the given chars with given style to text at given index. -
addCharsWithStyleString
Adds the given chars to text with given style string. -
removeChars
public void removeChars(int aStart, int anEnd) Deletes the given range of chars. -
replaceChars
Replaces the current selection with the given string. -
replaceChars
Replaces the current selection with the given string. -
replaceCharsWithStyle
public void replaceCharsWithStyle(CharSequence theChars, TextStyle textStyle, int aStart, int anEnd) Replaces the current selection with the given string. -
delete
public void delete()Deletes the current selection. -
replaceCharsWithContent
Replaces the current selection with the given contents (TextBlock or String). -
clear
public void clear()Clears the text. -
getLineCount
public int getLineCount()Returns the number of lines. -
getLine
Returns the individual line at given index. -
getLineForCharIndex
Returns the line for the given character index. -
getTokenForCharIndex
Returns the token for given character index. -
getCharIndexForXY
public int getCharIndexForXY(double anX, double aY) Returns the char index for given point in text coordinate space. -
paintFront
Paint text.- Overrides:
paintFront
in classView
-
processEvent
Process event. Make this public so TextArea can be used to edit text outside of normal Views.- Overrides:
processEvent
in classView
-
mousePressed
Handles mouse pressed. -
mouseDragged
Handles mouse dragged. -
mouseReleased
Handles mouse released. -
mouseMoved
Handle MouseMoved. -
keyPressed
Called when a key is pressed. -
keyTyped
Called when a key is typed. -
keyReleased
Called when a key is released. -
processActionEvent
Called when action event is received. -
getFontScale
public double getFontScale()Returns the font scale of the text box. -
setFontScale
public void setFontScale(double aValue) Sets the font scale of the text box. -
scaleTextToFit
public void scaleTextToFit()Scales font sizes of all text in TextBox to fit in bounds by finding/setting FontScale. -
cut
public void cut()Copies the current selection onto the clip board, then deletes the current selection. -
copy
public void copy()Copies the current selection onto the clipboard. -
paste
public void paste()Pasts the current clipboard data over the current selection. -
getClipboardContent
Returns the clipboard content. -
getUndoer
Returns the undoer. -
undo
public void undo()Called to undo the last text change. -
redo
public void redo()Called to redo the last text change. -
getPrefWidthImpl
protected double getPrefWidthImpl(double aH) Returns the width needed to display all characters.- Overrides:
getPrefWidthImpl
in classView
-
getPrefHeightImpl
protected double getPrefHeightImpl(double aW) Returns the height needed to display all characters.- Overrides:
getPrefHeightImpl
in classView
-
setFont
Sets the font of the current selection or cursor.- Overrides:
setFont
in classParentView
-
parentFontChanged
protected void parentFontChanged()Override to update font.- Overrides:
parentFontChanged
in classParentView
-
handleTextAdapterPropChange
Called when TextAdapter has prop change. -
handleSourceTextPropChange
Called when SourceText changes (chars added, updated or deleted). -
isHyphenating
public static boolean isHyphenating()Returns whether layout tries to hyphenate wrapped words. -
setHyphenating
public static void setHyphenating(boolean aValue) Sets whether layout tries to hyphenate wrapped words. -
getValuePropName
Returns a mapped property name.- Overrides:
getValuePropName
in classView
-
toString
Standard toString implementation.- Overrides:
toString
in classPropObject
-
initProps
Override to support properties for this class.- Overrides:
initProps
in classParentView
-
getPropValue
Override to support properties for this class.- Overrides:
getPropValue
in classParentView
-
setPropValue
Override to support properties for this class.- Overrides:
setPropValue
in classParentView
-
toXML
XML archival.- Specified by:
toXML
in interfaceXMLArchiver.Archivable
- Overrides:
toXML
in classParentView
-
fromXML
XML unarchival.- Specified by:
fromXML
in interfaceXMLArchiver.Archivable
- Overrides:
fromXML
in classParentView
-