Top Description Methods
org.fxmisc.richtext

public Interface CaretSelectionBind<PS, SEG, S>

extends Selection<PS, SEG, S>, Caret
Known Direct Implementers
org.fxmisc.richtext.CaretSelectionBindImpl
Type Parameters
<PS>
type for StyledDocument's paragraph style; only necessary when using the "selectedDocument" getter or property
<SEG>
type for StyledDocument's segment type; only necessary when using the "selectedDocument" getter or property
<S>
type for StyledDocument's segment style; only necessary when using the "selectedDocument" getter or property
Imports
javafx.beans.value.ObservableValue, javafx.scene.control.IndexRange, org.fxmisc.richtext.model.StyledDocument, java.text.BreakIterator

An object for encapsulating a caret and a selection in a given area where the caret and selection are bound to one another. In other words, selecting some range in the area (via 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:

  1. getStartPosition()/getEndPosition(), which refers to a position somewhere in the entire area's content. It's bounds are 0 <= x <= area.getLength().
  2. getStartColumnPosition()/getEndColumnPosition(), which refers to a position somewhere in the current paragraph. It's bounds are 0 <= x <= area.getParagraphLength(index).
Note: when parameter names are "position" without the "column" prefix, they refer to the position in the entire area.

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, 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 getSelectedDocument() or selectedDocumentProperty(). If you are not going to use the "selectedDocument" getter or property, then just write the much simpler CaretSelectionBind<?, ?, ?> selection.

See Also
Caret, Selection

Method Summary

Modifier and TypeMethod and Description
public ObservableValue<Integer>
public ObservableValue<Integer>
public ObservableValue<Integer>
public void
deselect()

Redeclares as abstract: org.fxmisc.richtext.Selection.deselect.

Clears the selection while keeping the caret position the same.

public 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 getRange() selection}.

public 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.

public int
public int
public int
public CaretNode
public Selection<PS, SEG, S>
public void
moveBreaksBackwards(int numOfBreaks, BreakIterator breakIterator)

Redeclares org.fxmisc.richtext.Caret.moveBreaksBackwards.

Moves the caret backwards by the number of breaks and clears any selection

public void
moveBreaksForwards(int numOfBreaks, BreakIterator breakIterator)

Redeclares org.fxmisc.richtext.Caret.moveBreaksForwards.

Moves the caret forwards by the number of breaks and clears any selection

public default void
moveTo(int position)

Implements org.fxmisc.richtext.Caret.moveTo.

Moves the caret to the given position in the text and clears any selection.

public default void
moveTo(int paragraphIndex, int columnPosition)

Implements org.fxmisc.richtext.Caret.moveTo.

Moves the caret to the position returned from TextEditingArea#getAbsolutePosition(int, int) and clears any selection.

public default void
moveTo(int pos, NavigationActions.SelectionPolicy selectionPolicy)

Moves the caret to the position indicated by pos.

public void
moveTo(int paragraphIndex, int columnIndex, NavigationActions.SelectionPolicy selectionPolicy)

Moves the caret to the position returned from TextEditingArea#getAbsolutePosition(int, int).

public default void
moveToAreaEnd()

Implements org.fxmisc.richtext.Caret.moveToAreaEnd.

Moves the caret to the end of the area and clears any selection

public void
public default void
moveToAreaStart()

Overrides default org.fxmisc.richtext.Caret.moveToAreaStart.

Moves the caret to the beginning of the area and clears any selection

public void
public default void
moveToNextChar()

Implements org.fxmisc.richtext.Caret.moveToNextChar.

Moves the caret forward one char in the text and clears any selection

public void
moveToNextChar(NavigationActions.SelectionPolicy selectionPolicy)

Moves the caret forward one char in the text.

public default void
moveToParEnd()

Implements org.fxmisc.richtext.Caret.moveToParEnd.

Moves the caret to the end of the current paragraph and clears any selection

public void
public default void
moveToParStart()

Implements org.fxmisc.richtext.Caret.moveToParStart.

Moves the caret to the beginning of the current paragraph and clears any selection

public void
public default void
moveToPrevChar()

Implements org.fxmisc.richtext.Caret.moveToPrevChar.

Moves the caret backward one char in the text and clears any selection

public void
moveToPrevChar(NavigationActions.SelectionPolicy selectionPolicy)

Moves the caret backward one char in the text.

public void
selectAll()

Redeclares org.fxmisc.richtext.Selection.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

public void
selectParagraph(int paragraphIndex)

Redeclares org.fxmisc.richtext.Selection.selectParagraph.

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

public default void
public void
selectRange(int startParagraphIndex, int startColPosition, int endParagraphIndex, int endColPosition)

Redeclares org.fxmisc.richtext.Selection.selectRange.

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

Caution

see TextEditingArea#getAbsolutePosition(int, int) to know how the column index argument can affect the returned position.

public void
selectRange(int startPosition, int endPosition)

Redeclares org.fxmisc.richtext.Selection.selectRange.

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

public void
selectRangeExpl(int anchorParagraph, int anchorColumn, int caretParagraph, int caretColumn)

Positions the anchor and caretPosition explicitly, effectively creating a selection.

public void
selectRangeExpl(int anchorPosition, int caretPosition)

Positions the anchor and caretPosition explicitly, effectively creating a selection.

public void
selectWord(int wordPositionInArea)

Redeclares org.fxmisc.richtext.Selection.selectWord.

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

public default void
selectWord()

Selects the word closest to the caret

public void
public void
public void
public void
public void
updateEndTo(int paragraphIndex, int columnPosition)

Redeclares org.fxmisc.richtext.Selection.updateEndTo.

public void
public void
public void
public void
public void
updateStartTo(int paragraphIndex, int columnPosition)

Redeclares org.fxmisc.richtext.Selection.updateStartTo.

Inherited from org.fxmisc.richtext.Caret:
beingUpdatedPropertyblinkRatePropertycaretBoundsPropertyclearTargetOffsetcolumnPositionPropertydisposegetAreagetBlinkRategetCaretBoundsgetCaretNamegetColumnPositiongetLineIndexgetParagraphIndexgetPositiongetShowCaretgetTargetOffsetisBeingUpdatedisVisiblelineIndexPropertymoveSentenceBreaksBackwardsmoveSentenceBreaksForwardsmoveWordBreaksBackwardsmoveWordBreaksForwardsparagraphIndexPropertypositionPropertysetBlinkRatesetShowCaretshowCaretPropertyvisibleProperty
Inherited from org.fxmisc.richtext.Selection:
beingUpdatedPropertyconfigureSelectionPathdisposeendColumnPositionPropertyendParagraphIndexPropertyendPositionPropertygetAreagetEndColumnPositiongetEndParagraphIndexgetEndPositiongetLengthgetParagraphSpangetRangegetSelectedDocumentgetSelectedTextgetSelectionBoundsgetSelectionNamegetStartColumnPositiongetStartParagraphIndexgetStartPositionisBeingUpdatedlengthPropertyparagraphSpanPropertyrangePropertyselectedDocumentPropertyselectedTextPropertyselectionBoundsPropertystartColumnPositionPropertystartParagraphIndexPropertystartPositionProperty

Method Detail

anchorColPositionPropertyback to summary
public ObservableValue<Integer> anchorColPositionProperty()
anchorParIndexPropertyback to summary
public ObservableValue<Integer> anchorParIndexProperty()
anchorPositionPropertyback to summary
public ObservableValue<Integer> anchorPositionProperty()
deselectback to summary
public void deselect()

Redeclares as abstract: org.fxmisc.richtext.Selection.deselect.

Clears the selection while keeping the caret position the same.

Annotations
@Override
displaceCaretback to summary
public 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 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.

displaceSelectionback to summary
public 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. 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.

getAnchorColPositionback to summary
public int getAnchorColPosition()
getAnchorParIndexback to summary
public int getAnchorParIndex()
getAnchorPositionback to summary
public int getAnchorPosition()
getUnderlyingCaretback to summary
public CaretNode getUnderlyingCaret()
getUnderlyingSelectionback to summary
public Selection<PS, SEG, S> getUnderlyingSelection()
moveBreaksBackwardsback to summary
public void moveBreaksBackwards(int numOfBreaks, BreakIterator breakIterator)

Redeclares org.fxmisc.richtext.Caret.moveBreaksBackwards.

Moves the caret backwards by the number of breaks and clears any selection

Annotations
@Override
moveBreaksForwardsback to summary
public void moveBreaksForwards(int numOfBreaks, BreakIterator breakIterator)

Redeclares org.fxmisc.richtext.Caret.moveBreaksForwards.

Moves the caret forwards by the number of breaks and clears any selection

Annotations
@Override
moveToback to summary
public default void moveTo(int position)

Implements org.fxmisc.richtext.Caret.moveTo.

Moves the caret to the given position in the text and clears any selection.

Annotations
@Override
moveToback to summary
public default void moveTo(int paragraphIndex, int columnPosition)

Implements org.fxmisc.richtext.Caret.moveTo.

Moves the caret to the position returned from TextEditingArea#getAbsolutePosition(int, int) and clears any selection.

Annotations
@Override
moveToback to summary
public default void moveTo(int pos, NavigationActions.SelectionPolicy selectionPolicy)

Moves the caret to the position indicated by 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.

moveToback to summary
public void moveTo(int paragraphIndex, int columnIndex, NavigationActions.SelectionPolicy selectionPolicy)

Moves the caret to the position returned from TextEditingArea#getAbsolutePosition(int, int).

moveToAreaEndback to summary
public default void moveToAreaEnd()

Implements org.fxmisc.richtext.Caret.moveToAreaEnd.

Moves the caret to the end of the area and clears any selection

Annotations
@Override
moveToAreaEndback to summary
public void moveToAreaEnd(NavigationActions.SelectionPolicy selectionPolicy)
moveToAreaStartback to summary
public default void moveToAreaStart()

Overrides default org.fxmisc.richtext.Caret.moveToAreaStart.

Moves the caret to the beginning of the area and clears any selection

Annotations
@Override
moveToAreaStartback to summary
public void moveToAreaStart(NavigationActions.SelectionPolicy selectionPolicy)
moveToNextCharback to summary
public default void moveToNextChar()

Implements org.fxmisc.richtext.Caret.moveToNextChar.

Moves the caret forward one char in the text and clears any selection

Annotations
@Override
moveToNextCharback to summary
public void moveToNextChar(NavigationActions.SelectionPolicy selectionPolicy)

Moves the caret forward one char in the text. Based on the given selection policy, anchor either moves with the caret, stays put, or moves to the former caret position.

moveToParEndback to summary
public default void moveToParEnd()

Implements org.fxmisc.richtext.Caret.moveToParEnd.

Moves the caret to the end of the current paragraph and clears any selection

Annotations
@Override
moveToParEndback to summary
public void moveToParEnd(NavigationActions.SelectionPolicy selectionPolicy)
moveToParStartback to summary
public default void moveToParStart()

Implements org.fxmisc.richtext.Caret.moveToParStart.

Moves the caret to the beginning of the current paragraph and clears any selection

Annotations
@Override
moveToParStartback to summary
public void moveToParStart(NavigationActions.SelectionPolicy selectionPolicy)
moveToPrevCharback to summary
public default void moveToPrevChar()

Implements org.fxmisc.richtext.Caret.moveToPrevChar.

Moves the caret backward one char in the text and clears any selection

Annotations
@Override
moveToPrevCharback to summary
public void moveToPrevChar(NavigationActions.SelectionPolicy selectionPolicy)

Moves the caret backward one char in the text. Based on the given selection policy, anchor either moves with the caret, stays put, or moves to the former caret position.

selectAllback to summary
public void selectAll()

Redeclares org.fxmisc.richtext.Selection.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

Annotations
@Override
selectParagraphback to summary
public void selectParagraph(int paragraphIndex)

Redeclares org.fxmisc.richtext.Selection.selectParagraph.

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

Annotations
@Override
selectParagraphback to summary
public default void selectParagraph()
selectRangeback to summary
public void selectRange(int startParagraphIndex, int startColPosition, int endParagraphIndex, int endColPosition)

Redeclares org.fxmisc.richtext.Selection.selectRange.

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

Caution

see TextEditingArea#getAbsolutePosition(int, int) to know how the column index argument can affect the returned position.

Annotations
@Override
selectRangeback to summary
public void selectRange(int startPosition, int endPosition)

Redeclares org.fxmisc.richtext.Selection.selectRange.

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

Annotations
@Override
selectRangeExplback to summary
public void selectRangeExpl(int anchorParagraph, int anchorColumn, int caretParagraph, int caretColumn)

Positions the anchor and caretPosition explicitly, effectively creating a selection.

selectRangeExplback to summary
public void selectRangeExpl(int anchorPosition, int caretPosition)

Positions the anchor and caretPosition explicitly, effectively creating a selection.

selectWordback to summary
public void selectWord(int wordPositionInArea)

Redeclares org.fxmisc.richtext.Selection.selectWord.

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

Annotations
@Override
selectWordback to summary
public default void selectWord()

Selects the word closest to the caret

updateEndByback to summary
public void updateEndBy(int amount, Selection.Direction direction)

Redeclares org.fxmisc.richtext.Selection.updateEndBy.

Annotations
@Override
updateEndByBreaksBackwardback to summary
public void updateEndByBreaksBackward(int numOfBreaks, BreakIterator breakIterator)

Redeclares org.fxmisc.richtext.Selection.updateEndByBreaksBackward.

Annotations
@Override
updateEndByBreaksForwardback to summary
public void updateEndByBreaksForward(int numOfBreaks, BreakIterator breakIterator)

Redeclares org.fxmisc.richtext.Selection.updateEndByBreaksForward.

Annotations
@Override
updateEndToback to summary
public void updateEndTo(int position)

Redeclares org.fxmisc.richtext.Selection.updateEndTo.

Annotations
@Override
updateEndToback to summary
public void updateEndTo(int paragraphIndex, int columnPosition)

Redeclares org.fxmisc.richtext.Selection.updateEndTo.

Annotations
@Override
updateStartByback to summary
public void updateStartBy(int amount, Selection.Direction direction)

Redeclares org.fxmisc.richtext.Selection.updateStartBy.

Annotations
@Override
updateStartByBreaksBackwardback to summary
public void updateStartByBreaksBackward(int numOfBreaks, BreakIterator breakIterator)

Redeclares org.fxmisc.richtext.Selection.updateStartByBreaksBackward.

Annotations
@Override
updateStartByBreaksForwardback to summary
public void updateStartByBreaksForward(int numOfBreaks, BreakIterator breakIterator)

Redeclares org.fxmisc.richtext.Selection.updateStartByBreaksForward.

Annotations
@Override
updateStartToback to summary
public void updateStartTo(int position)

Redeclares org.fxmisc.richtext.Selection.updateStartTo.

Annotations
@Override
updateStartToback to summary
public void updateStartTo(int paragraphIndex, int columnPosition)

Redeclares org.fxmisc.richtext.Selection.updateStartTo.

Annotations
@Override