public class TextAreaSkin extends TextInputControlSkin<TextArea>
Default skin implementation for the
TextArea
control.- Since:
- 9
- See Also:
TextArea
-
Property Summary
Properties inherited from class javafx.scene.control.skin.TextInputControlSkin
forwardBias, highlightFill, highlightTextFill, promptTextFill, textFill
-
Nested Class Summary
Nested classes/interfaces inherited from class javafx.scene.control.skin.TextInputControlSkin
TextInputControlSkin.Direction, TextInputControlSkin.TextUnit
-
Constructor Summary
Constructors Constructor Description TextAreaSkin(TextArea control)
Creates a new TextAreaSkin instance, installing the necessary child nodes into the Controlchildren
list, as well as the necessary input mappings for handling key, mouse, etc events. -
Method Summary
Modifier and Type Method Description protected void
addHighlight(List<? extends Node> nodes, int start)
Adds highlight for composed text from Input Method.double
computeBaselineOffset(double topInset, double rightInset, double bottomInset, double leftInset)
Calculates the baseline offset based on the first managed child.void
dispose()
Called by a Skinnable when the Skin is replaced on the Skinnable.Bounds
getCaretBounds()
Gets theBounds
of the caret of the skinnedTextArea
.Rectangle2D
getCharacterBounds(int index)
Returns the bounds of the character at a given index.HitInfo
getIndex(double x, double y)
Performs a hit test, mapping point to index in the content.protected int
getInsertionPoint(double x, double y)
Returns the insertion point for a given location.Point2D
getMenuPosition()
Returns the position to be used for a context menu, based on the location of the caret handle or selection handles.protected PathElement[]
getRangeShape(int start, int end)
protected PathElement[]
getUnderlineShape(int start, int end)
protected void
invalidateMetrics()
Invalidates cached min and pref sizes for the TextInputControl.protected void
layoutChildren(double contentX, double contentY, double contentWidth, double contentHeight)
Called during the layout pass of the scenegraph.void
moveCaret(TextInputControlSkin.TextUnit unit, TextInputControlSkin.Direction dir, boolean select)
Moves the caret by one of the given text unit, in the given direction.void
positionCaret(HitInfo hit, boolean select)
Moves the caret to the specified position.protected Object
queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)
This method is called by the assistive technology to request the value for an attribute.protected void
removeHighlight(List<? extends Node> nodes)
Removes highlight for composed text from Input Method.protected void
scrollCharacterToVisible(int index)
Ensures that the character at a given index is visible.protected void
updateHighlightFill()
Called when highlightFill property changes.Methods inherited from class javafx.scene.control.skin.TextInputControlSkin
executeAccessibleAction, forwardBiasProperty, getClassCssMetaData, getCssMetaData, getHighlightFill, getHighlightTextFill, getPromptTextFill, getTextFill, handleInputMethodEvent, highlightFillProperty, highlightTextFillProperty, isForwardBias, maskText, promptTextFillProperty, setCaretAnimating, setForwardBias, setHighlightFill, setHighlightTextFill, setPromptTextFill, setTextFill, textFillProperty, updateHighlightTextFill, updateTextFill
Methods inherited from class javafx.scene.control.SkinBase
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, consumeMouseEvents, getChildren, getNode, getSkinnable, layoutInArea, layoutInArea, layoutInArea, positionInArea, positionInArea, pseudoClassStateChanged, registerChangeListener, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, unregisterChangeListeners
-
Constructor Details
-
TextAreaSkin
Creates a new TextAreaSkin instance, installing the necessary child nodes into the Controlchildren
list, as well as the necessary input mappings for handling key, mouse, etc events.- Parameters:
control
- The control that this skin should be installed onto.
-
-
Method Details
-
invalidateMetrics
protected void invalidateMetrics()Invalidates cached min and pref sizes for the TextInputControl.- Overrides:
invalidateMetrics
in classTextInputControlSkin<TextArea>
-
layoutChildren
protected void layoutChildren(double contentX, double contentY, double contentWidth, double contentHeight)Called during the layout pass of the scenegraph.- Overrides:
layoutChildren
in classSkinBase<TextArea>
- Parameters:
contentX
- the x positioncontentY
- the y positioncontentWidth
- the widthcontentHeight
- the height
-
updateHighlightFill
protected void updateHighlightFill()Called when highlightFill property changes.- Overrides:
updateHighlightFill
in classTextInputControlSkin<TextArea>
-
getIndex
Performs a hit test, mapping point to index in the content.- Parameters:
x
- the x coordinate of the point.y
- the y coordinate of the point.- Returns:
- a
HitInfo
object describing the index and forward bias.
-
moveCaret
public void moveCaret(TextInputControlSkin.TextUnit unit, TextInputControlSkin.Direction dir, boolean select)Moves the caret by one of the given text unit, in the given direction. Note that only certain combinations are valid, depending on the implementing subclass.- Specified by:
moveCaret
in classTextInputControlSkin<TextArea>
- Parameters:
unit
- the unit of text to move by.dir
- the direction of movement.select
- whether to extends the selection to the new posititon.
-
getUnderlineShape
- Specified by:
getUnderlineShape
in classTextInputControlSkin<TextArea>
- Parameters:
start
- the startend
- the end- Returns:
- the path elements describing the shape of the underline for the given range.
-
getRangeShape
- Specified by:
getRangeShape
in classTextInputControlSkin<TextArea>
- Parameters:
start
- the startend
- the end- Returns:
- the path elements describing the bounding rectangles for the given range of text.
-
addHighlight
Adds highlight for composed text from Input Method.- Specified by:
addHighlight
in classTextInputControlSkin<TextArea>
- Parameters:
nodes
- the list of nodesstart
- the start
-
removeHighlight
Removes highlight for composed text from Input Method.- Specified by:
removeHighlight
in classTextInputControlSkin<TextArea>
- Parameters:
nodes
- the list of nodes
-
getMenuPosition
Returns the position to be used for a context menu, based on the location of the caret handle or selection handles. This is supported only on touch displays and does not use the location of the mouse.- Overrides:
getMenuPosition
in classTextInputControlSkin<TextArea>
- Returns:
- the position to be used for this context menu
-
getCaretBounds
Gets theBounds
of the caret of the skinnedTextArea
.- Returns:
- the
Bounds
of the caret shape, relative to theTextArea
.
-
queryAccessibleAttribute
This method is called by the assistive technology to request the value for an attribute.This method is commonly overridden by subclasses to implement attributes that are required for a specific role.
If a particular attribute is not handled, the superclass implementation must be called.- Overrides:
queryAccessibleAttribute
in classSkinBase<TextArea>
- Parameters:
attribute
- the requested attributeparameters
- optional list of parameters- Returns:
- the value for the requested attribute
- See Also:
AccessibleAttribute
,Node.queryAccessibleAttribute(javafx.scene.AccessibleAttribute, java.lang.Object...)
-
dispose
public void dispose()Called by a Skinnable when the Skin is replaced on the Skinnable. This method allows a Skin to implement any logic necessary to clean up itself after the Skin is no longer needed. It may be used to release native resources. The methodsSkin.getSkinnable()
andSkin.getNode()
should return null following a call to dispose. Calling dispose twice has no effect. -
computeBaselineOffset
public double computeBaselineOffset(double topInset, double rightInset, double bottomInset, double leftInset)Calculates the baseline offset based on the first managed child. If there is no such child, returnsNode.getBaselineOffset()
.- Overrides:
computeBaselineOffset
in classSkinBase<TextArea>
- Parameters:
topInset
- the pixel snapped top insetrightInset
- the pixel snapped right insetbottomInset
- the pixel snapped bottom insetleftInset
- the pixel snapped left inset- Returns:
- baseline offset
-
getInsertionPoint
protected int getInsertionPoint(double x, double y)Returns the insertion point for a given location.- Overrides:
getInsertionPoint
in classTextInputControlSkin<TextArea>
- Parameters:
x
- the x locationy
- the y location- Returns:
- the insertion point for a given location
-
positionCaret
Moves the caret to the specified position.- Parameters:
hit
- the new position and forward bias of the caret.select
- whether to extend selection to the new position.
-
getCharacterBounds
Returns the bounds of the character at a given index.- Overrides:
getCharacterBounds
in classTextInputControlSkin<TextArea>
- Parameters:
index
- the index- Returns:
- the bounds of the character at a given index
-
scrollCharacterToVisible
protected void scrollCharacterToVisible(int index)Ensures that the character at a given index is visible.- Overrides:
scrollCharacterToVisible
in classTextInputControlSkin<TextArea>
- Parameters:
index
- the index
-