public class TextFieldSkin extends TextInputControlSkin<TextField>
TextField
control.TextField
caretVisibleProperty, forwardBiasProperty, highlightFillProperty, highlightTextFillProperty, promptTextFillProperty, textFillProperty
TextInputControlSkin.Direction, TextInputControlSkin.TextUnit
Modifier and Type | Field and Description |
---|---|
private TextFieldBehavior |
behavior
Private fields
|
(package private) static char |
BULLET |
private double |
caretWidth |
private Path |
characterBoundingPath |
private Rectangle |
clip
The clip, applied to the textGroup.
|
private Group |
handleGroup |
private double |
pressX |
private double |
pressY |
private Text |
promptNode
The node used for showing the prompt text.
|
private Path |
selectionHighlightPath
A path, provided by the textNode, which represents the area
which is selected.
|
private Pane |
textGroup
This group contains the text, caret, and selection rectangle.
|
private Text |
textNode
The node actually displaying the text.
|
private ObservableDoubleValue |
textRight
Right edge of the text region sans padding
|
private DoubleProperty |
textTranslateX |
private ObservableBooleanValue |
usePromptText |
caretHandle, caretPath, fontMetrics, preload, selectionHandle1, selectionHandle2, SHOW_HANDLES
Constructor and Description |
---|
TextFieldSkin(TextField control)
Creates a new TextFieldSkin instance, installing the necessary child
nodes into the Control
children list, as
well as the necessary input mappings for handling key, mouse, etc events. |
Modifier and Type | Method and Description |
---|---|
protected void |
addHighlight(java.util.List<? extends Node> nodes,
int start)
Adds highlight for composed text from Input Method.
|
double |
computeBaselineOffset(double topInset,
double rightInset,
double bottomInset,
double leftInset) |
protected double |
computeMaxHeight(double width,
double topInset,
double rightInset,
double bottomInset,
double leftInset) |
protected double |
computeMinHeight(double width,
double topInset,
double rightInset,
double bottomInset,
double leftInset) |
protected double |
computePrefHeight(double width,
double topInset,
double rightInset,
double bottomInset,
double leftInset) |
protected double |
computePrefWidth(double height,
double topInset,
double rightInset,
double bottomInset,
double leftInset) |
private void |
createPromptNode() |
void |
deleteChar(boolean previous)
Deletes the character that follows or precedes the current
caret position from the text if there is no selection, or
deletes the selection if there is one.
|
void |
dispose() |
(package private) TextInputControlBehavior |
getBehavior()
Private implementation
|
Rectangle2D |
getCharacterBounds(int index)
Returns the bounds of the character at a given index.
|
private HPos |
getHAlignment() |
HitInfo |
getIndex(double x,
double y)
Performs a hit test, mapping point to index in the content.
|
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 |
layoutChildren(double x,
double y,
double w,
double h) |
protected java.lang.String |
maskText(java.lang.String txt)
This method may be overridden by subclasses to replace the displayed
characters without affecting the actual text content.
|
void |
moveCaret(TextInputControlSkin.TextUnit unit,
TextInputControlSkin.Direction dir,
boolean select)
Moves the caret by one of the given text unit, in the given
direction.
|
private void |
nextCharacterVisually(boolean moveRight) |
void |
positionCaret(HitInfo hit,
boolean select)
Moves the caret to the specified position.
|
private void |
positionCaret(int pos,
boolean leading,
boolean select) |
protected java.lang.Object |
queryAccessibleAttribute(AccessibleAttribute attribute,
java.lang.Object... parameters) |
protected void |
removeHighlight(java.util.List<? extends Node> nodes)
Removes highlight for composed text from Input Method.
|
void |
replaceText(int start,
int end,
java.lang.String txt)
Replaces a range of characters with the given text.
|
private void |
scrollAfterDelete(double textMaxXOld,
double caretMaxXOld) |
private void |
updateCaretOff() |
private void |
updateSelection() |
private void |
updateTextNodeCaretPos(int pos) |
private void |
updateTextPos()
Updates the textTranslateX value for the Text node position.
|
caretVisibleProperty, executeAccessibleAction, forwardBiasProperty, getClassCssMetaData, getCssMetaData, getHighlightFill, getHighlightTextFill, getInsertionPoint, getPromptTextFill, getTextFill, handleInputMethodEvent, highlightFillProperty, highlightTextFillProperty, invalidateMetrics, isForwardBias, isRTL, promptTextFillProperty, scrollCharacterToVisible, setCaretAnimating, setForwardBias, setHighlightFill, setHighlightTextFill, setPromptTextFill, setTextFill, textFillProperty, updateHighlightFill, updateHighlightTextFill, updateTextFill
private final TextFieldBehavior behavior
private Pane textGroup
private Group handleGroup
private Rectangle clip
private Text textNode
private Text promptNode
private Path selectionHighlightPath
private Path characterBoundingPath
private ObservableBooleanValue usePromptText
private DoubleProperty textTranslateX
private double caretWidth
private ObservableDoubleValue textRight
private double pressX
private double pressY
static final char BULLET
public TextFieldSkin(TextField control)
children
list, as
well as the necessary input mappings for handling key, mouse, etc events.control
- The control that this skin should be installed onto.public void dispose()
protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset)
protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)
protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)
protected double computeMaxHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset)
public double computeBaselineOffset(double topInset, double rightInset, double bottomInset, double leftInset)
public void replaceText(int start, int end, java.lang.String txt)
start
- The starting index in the range, inclusive. This must be >= 0 and < the end.end
- The ending index in the range, exclusive. This is one-past the last character to
delete (consistent with the String manipulation methods). This must be > the start,
and <= the length of the text.txt
- The text that is to replace the range. This must not be null.TextField#replaceText(int, int, String)
public void deleteChar(boolean previous)
previous
- whether to delete the preceding character.public HitInfo getIndex(double x, double y)
x
- the x coordinate of the point.y
- the y coordinate of the point.HitInfo
object describing the index and forward bias.public void positionCaret(HitInfo hit, boolean select)
hit
- the new position and forward bias of the caret.select
- whether to extend selection to the new position.private void positionCaret(int pos, boolean leading, boolean select)
public Rectangle2D getCharacterBounds(int index)
getCharacterBounds
in class TextInputControlSkin<TextField>
index
- the indexprotected PathElement[] getUnderlineShape(int start, int end)
getUnderlineShape
in class TextInputControlSkin<TextField>
start
- the startend
- the endprotected PathElement[] getRangeShape(int start, int end)
getRangeShape
in class TextInputControlSkin<TextField>
start
- the startend
- the endprotected void addHighlight(java.util.List<? extends Node> nodes, int start)
addHighlight
in class TextInputControlSkin<TextField>
nodes
- the list of nodesstart
- the startprotected void removeHighlight(java.util.List<? extends Node> nodes)
removeHighlight
in class TextInputControlSkin<TextField>
nodes
- the list of nodespublic void moveCaret(TextInputControlSkin.TextUnit unit, TextInputControlSkin.Direction dir, boolean select)
moveCaret
in class TextInputControlSkin<TextField>
unit
- the unit of text to move by.dir
- the direction of movement.select
- whether to extends the selection to the new posititon.private void nextCharacterVisually(boolean moveRight)
protected void layoutChildren(double x, double y, double w, double h)
private HPos getHAlignment()
public Point2D getMenuPosition()
getMenuPosition
in class TextInputControlSkin<TextField>
protected java.lang.String maskText(java.lang.String txt)
maskText
in class TextInputControlSkin<TextField>
txt
- the content that may need to be masked.protected java.lang.Object queryAccessibleAttribute(AccessibleAttribute attribute, java.lang.Object... parameters)
TextInputControlBehavior getBehavior()
getBehavior
in class TextInputControlSkin<TextField>
private void updateTextNodeCaretPos(int pos)
private void createPromptNode()
private void updateSelection()
private void updateTextPos()
private void updateCaretOff()
private void scrollAfterDelete(double textMaxXOld, double caretMaxXOld)