PS
- type for StyledDocument
's paragraph style; only necessary when using the "selectedDocument"
getter or propertySEG
- type for StyledDocument
's segment type; only necessary when using the "selectedDocument"
getter or propertyS
- type for StyledDocument
's segment style; only necessary when using the "selectedDocument"
getter or propertypublic interface CaretSelectionBind<PS,SEG,S> extends Selection<PS,SEG,S>, Caret
selectRangeExpl(int, int)
,
selectRange(int, int, int, int)
) will move the caret in the same call, except if one uses
displaceSelection(int, int)
. Updating the selection via any method with an "update" prefix from
Selection
will also move the caret if it has been displaced
or the anchor is
not the boundary (i.e. the selection's the start or end position) that is being updated.
Likewise, moving the caret via the "move" prefix methods from Caret
will clear the selection in the same call, except if one uses displaceCaret(int)
.
"Position" refers to the place in-between characters. In other words, every "|"
in
"|t|e|x|t|"
is a valid position. There are two kinds of positions used here:
Selection.getStartPosition()
/Selection.getEndPosition()
, which refers to a position somewhere in the
entire area's content. It's bounds are 0 <= x <= area.getLength()
.
Selection.getStartColumnPosition()
/Selection.getEndColumnPosition()
, which refers to a position
somewhere in the current paragraph. It's bounds are 0 <= x <= area.getParagraphLength(index)
.
The selection is typically made using the anchor's position
and
the underlying caret's position
. Hence, selectRangeExpl(int, int)
is the typical method to use, although selectRange(int, int)
can also be used.
For type safety, Selection.getSelectedDocument()
requires the same generic types from StyledDocument
.
This means that one must write a lot of boilerplate for the generics:
CaretSelectionBind<Collection<String>, StyledText<Collection<String>>, Collection<String>> selection
.
However, this is only necessary if one is using Selection.getSelectedDocument()
or
Selection.selectedDocumentProperty()
. If you are not going to use the "selectedDocument" getter or property,
then just write the much simpler CaretSelectionBind<?, ?, ?> selection
.
Type | Property | Description |
---|---|---|
javafx.beans.value.ObservableValue<java.lang.Integer> |
anchorColPosition |
|
javafx.beans.value.ObservableValue<java.lang.Integer> |
anchorParIndex |
|
javafx.beans.value.ObservableValue<java.lang.Integer> |
anchorPosition |
beingUpdated, blinkRate, caretBounds, columnPosition, lineIndex, paragraphIndex, position, showCaret, visible
beingUpdated, endColumnPosition, endParagraphIndex, endPosition, length, paragraphSpan, range, selectedDocument, selectedText, selectionBounds, startColumnPosition, startParagraphIndex, startPosition
Caret.CaretVisibility
Selection.Direction
Modifier and Type | Method | Description |
---|---|---|
javafx.beans.value.ObservableValue<java.lang.Integer> |
anchorColPositionProperty() |
|
javafx.beans.value.ObservableValue<java.lang.Integer> |
anchorParIndexProperty() |
|
javafx.beans.value.ObservableValue<java.lang.Integer> |
anchorPositionProperty() |
|
void |
deselect() |
Clears the selection while keeping the caret position the same.
|
void |
displaceCaret(int position) |
Displaces the caret from the selection by positioning only the caret to the new location without
also affecting the selection's
getAnchorPosition() anchor} or the Selection.getRange() selection}. |
void |
displaceSelection(int startPosition,
int endPosition) |
Displaces the caret from the selection by positioning only the selection to the new location without
also affecting the
caret's position . |
int |
getAnchorColPosition() |
Gets the value of the property anchorColPosition.
|
int |
getAnchorParIndex() |
Gets the value of the property anchorParIndex.
|
int |
getAnchorPosition() |
Gets the value of the property anchorPosition.
|
CaretNode |
getUnderlyingCaret() |
|
Selection<PS,SEG,S> |
getUnderlyingSelection() |
|
void |
moveBreaksBackwards(int numOfBreaks,
java.text.BreakIterator breakIterator) |
Moves the caret backwards by the number of breaks and clears any selection
|
void |
moveBreaksForwards(int numOfBreaks,
java.text.BreakIterator breakIterator) |
Moves the caret forwards by the number of breaks and clears any selection
|
default void |
moveTo(int position) |
Moves the caret to the given position in the text and clears any selection.
|
default void |
moveTo(int paragraphIndex,
int columnPosition) |
Moves the caret to the position returned from
TextEditingArea.getAbsolutePosition(int, int)
and clears any selection. |
void |
moveTo(int paragraphIndex,
int columnIndex,
NavigationActions.SelectionPolicy selectionPolicy) |
Moves the caret to the position returned from
TextEditingArea.getAbsolutePosition(int, int) . |
default void |
moveTo(int pos,
NavigationActions.SelectionPolicy selectionPolicy) |
Moves the caret to the position indicated by
pos . |
default void |
moveToAreaEnd() |
Moves the caret to the end of the area and clears any selection
|
void |
moveToAreaEnd(NavigationActions.SelectionPolicy selectionPolicy) |
|
default void |
moveToAreaStart() |
Moves the caret to the beginning of the area and clears any selection
|
void |
moveToAreaStart(NavigationActions.SelectionPolicy selectionPolicy) |
|
default void |
moveToNextChar() |
Moves the caret forward one char in the text and clears any selection
|
void |
moveToNextChar(NavigationActions.SelectionPolicy selectionPolicy) |
Moves the caret forward one char in the text.
|
default void |
moveToParEnd() |
Moves the caret to the end of the current paragraph and clears any selection
|
void |
moveToParEnd(NavigationActions.SelectionPolicy selectionPolicy) |
|
default void |
moveToParStart() |
Moves the caret to the beginning of the current paragraph and clears any selection
|
void |
moveToParStart(NavigationActions.SelectionPolicy selectionPolicy) |
|
default void |
moveToPrevChar() |
Moves the caret backward one char in the text and clears any selection
|
void |
moveToPrevChar(NavigationActions.SelectionPolicy selectionPolicy) |
Moves the caret backward one char in the text.
|
void |
selectAll() |
Selects everything in the area and moves the caret to either the start of the new selection if the anchor was
equal to the original start or the end if the anchor was equal to the original end
|
default void |
selectParagraph() |
|
void |
selectParagraph(int paragraphIndex) |
Selects the given paragraph and moves the caret to either the start of the new selection if the anchor was
equal to the original start or the end if the anchor was equal to the original end
|
void |
selectRange(int startPosition,
int endPosition) |
Selects the given range and moves the caret to either the start of the new selection if the anchor was equal to
the original start or the end if the anchor was equal to the original end
|
void |
selectRange(int startParagraphIndex,
int startColPosition,
int endParagraphIndex,
int endColPosition) |
Selects the given range and moves the caret to either the start of the new selection if the anchor was equal to
the original start or the end if the anchor was equal to the original end
|
void |
selectRangeExpl(int anchorPosition,
int caretPosition) |
Positions the anchor and caretPosition explicitly,
effectively creating a selection.
|
void |
selectRangeExpl(int anchorParagraph,
int anchorColumn,
int caretParagraph,
int caretColumn) |
Positions the anchor and caretPosition explicitly,
effectively creating a selection.
|
default void |
selectWord() |
Selects the word closest to the caret
|
void |
selectWord(int wordPositionInArea) |
Selects the closest word to the given position in the area and moves the caret to either the start of the new
selection if the anchor was equal to the original start or the end if the anchor was equal to the original end
|
void |
updateEndBy(int amount,
Selection.Direction direction) |
|
void |
updateEndByBreaksBackward(int numOfBreaks,
java.text.BreakIterator breakIterator) |
|
void |
updateEndByBreaksForward(int numOfBreaks,
java.text.BreakIterator breakIterator) |
|
void |
updateEndTo(int position) |
|
void |
updateEndTo(int paragraphIndex,
int columnPosition) |
|
void |
updateStartBy(int amount,
Selection.Direction direction) |
|
void |
updateStartByBreaksBackward(int numOfBreaks,
java.text.BreakIterator breakIterator) |
|
void |
updateStartByBreaksForward(int numOfBreaks,
java.text.BreakIterator breakIterator) |
|
void |
updateStartTo(int position) |
|
void |
updateStartTo(int paragraphIndex,
int columnPosition) |
beingUpdatedProperty, blinkRateProperty, caretBoundsProperty, clearTargetOffset, columnPositionProperty, dispose, getArea, getBlinkRate, getCaretBounds, getCaretName, getColumnPosition, getLineIndex, getParagraphIndex, getPosition, getShowCaret, getTargetOffset, isBeingUpdated, isVisible, lineIndexProperty, moveSentenceBreaksBackwards, moveSentenceBreaksForwards, moveWordBreaksBackwards, moveWordBreaksForwards, paragraphIndexProperty, positionProperty, setBlinkRate, setShowCaret, showCaretProperty, visibleProperty
beingUpdatedProperty, configureSelectionPath, dispose, endColumnPositionProperty, endParagraphIndexProperty, endPositionProperty, getArea, getEndColumnPosition, getEndParagraphIndex, getEndPosition, getLength, getParagraphSpan, getRange, getSelectedDocument, getSelectedText, getSelectionBounds, getSelectionName, getStartColumnPosition, getStartParagraphIndex, getStartPosition, isBeingUpdated, lengthProperty, paragraphSpanProperty, rangeProperty, selectedDocumentProperty, selectedTextProperty, selectionBoundsProperty, startColumnPositionProperty, startParagraphIndexProperty, startPositionProperty
javafx.beans.value.ObservableValue<java.lang.Integer> anchorPositionProperty
getAnchorPosition()
javafx.beans.value.ObservableValue<java.lang.Integer> anchorParIndexProperty
getAnchorParIndex()
javafx.beans.value.ObservableValue<java.lang.Integer> anchorColPositionProperty
getAnchorColPosition()
CaretNode getUnderlyingCaret()
int getAnchorPosition()
javafx.beans.value.ObservableValue<java.lang.Integer> anchorPositionProperty()
getAnchorPosition()
int getAnchorParIndex()
javafx.beans.value.ObservableValue<java.lang.Integer> anchorParIndexProperty()
getAnchorParIndex()
int getAnchorColPosition()
javafx.beans.value.ObservableValue<java.lang.Integer> anchorColPositionProperty()
getAnchorColPosition()
default void moveTo(int position)
default void moveTo(int paragraphIndex, int columnPosition)
TextEditingArea.getAbsolutePosition(int, int)
and clears any selection.default void moveToParStart()
moveToParStart
in interface Caret
default void moveToParEnd()
moveToParEnd
in interface Caret
default void moveToAreaStart()
moveToAreaStart
in interface Caret
default void moveToAreaEnd()
moveToAreaEnd
in interface Caret
default void moveToPrevChar()
moveToPrevChar
in interface Caret
default void moveToNextChar()
moveToNextChar
in interface Caret
void moveBreaksForwards(int numOfBreaks, java.text.BreakIterator breakIterator)
moveBreaksForwards
in interface Caret
void moveBreaksBackwards(int numOfBreaks, java.text.BreakIterator breakIterator)
moveBreaksBackwards
in interface Caret
void selectRange(int startParagraphIndex, int startColPosition, int endParagraphIndex, int endColPosition)
Caution: see TextEditingArea.getAbsolutePosition(int, int)
to
know how the column index argument can affect the returned position.
selectRange
in interface Selection<PS,SEG,S>
void selectRange(int startPosition, int endPosition)
selectRange
in interface Selection<PS,SEG,S>
void updateStartBy(int amount, Selection.Direction direction)
updateStartBy
in interface Selection<PS,SEG,S>
void updateEndBy(int amount, Selection.Direction direction)
updateEndBy
in interface Selection<PS,SEG,S>
void updateStartTo(int position)
updateStartTo
in interface Selection<PS,SEG,S>
void updateStartTo(int paragraphIndex, int columnPosition)
updateStartTo
in interface Selection<PS,SEG,S>
void updateStartByBreaksForward(int numOfBreaks, java.text.BreakIterator breakIterator)
updateStartByBreaksForward
in interface Selection<PS,SEG,S>
void updateStartByBreaksBackward(int numOfBreaks, java.text.BreakIterator breakIterator)
updateStartByBreaksBackward
in interface Selection<PS,SEG,S>
void updateEndTo(int position)
updateEndTo
in interface Selection<PS,SEG,S>
void updateEndTo(int paragraphIndex, int columnPosition)
updateEndTo
in interface Selection<PS,SEG,S>
void updateEndByBreaksForward(int numOfBreaks, java.text.BreakIterator breakIterator)
updateEndByBreaksForward
in interface Selection<PS,SEG,S>
void updateEndByBreaksBackward(int numOfBreaks, java.text.BreakIterator breakIterator)
updateEndByBreaksBackward
in interface Selection<PS,SEG,S>
void selectAll()
void selectParagraph(int paragraphIndex)
selectParagraph
in interface Selection<PS,SEG,S>
void selectWord(int wordPositionInArea)
selectWord
in interface Selection<PS,SEG,S>
void deselect()
void selectRangeExpl(int anchorParagraph, int anchorColumn, int caretParagraph, int caretColumn)
void selectRangeExpl(int anchorPosition, int caretPosition)
default void moveTo(int pos, NavigationActions.SelectionPolicy selectionPolicy)
pos
.
Based on the selection policy, the selection is either cleared
(i.e. anchor is set to the same position as caret), adjusted
(i.e. anchor is not moved at all), or extended
(i.e. pos
becomes the new caret and, if pos
points
outside the current selection, the far end of the current selection
becomes the anchor.void moveTo(int paragraphIndex, int columnIndex, NavigationActions.SelectionPolicy selectionPolicy)
TextEditingArea.getAbsolutePosition(int, int)
.void moveToPrevChar(NavigationActions.SelectionPolicy selectionPolicy)
void moveToNextChar(NavigationActions.SelectionPolicy selectionPolicy)
void moveToParStart(NavigationActions.SelectionPolicy selectionPolicy)
void moveToParEnd(NavigationActions.SelectionPolicy selectionPolicy)
void moveToAreaStart(NavigationActions.SelectionPolicy selectionPolicy)
void moveToAreaEnd(NavigationActions.SelectionPolicy selectionPolicy)
default void selectParagraph()
default void selectWord()
void displaceCaret(int position)
getAnchorPosition()
anchor} or the Selection.getRange()
selection}.
Do not confuse this method with moveTo(int)
, which is the normal way of moving the caret.
This method can be used to achieve the special case of positioning the caret outside or inside the selection,
as opposed to always being at the boundary. Use with care.void displaceSelection(int startPosition, int endPosition)
caret's position
.
This method can be used to achieve the special case of selecting some range in the area without affecting the
caret's position. Use with care.