Package org.fxmisc.richtext
Interface Caret
-
- All Known Subinterfaces:
CaretSelectionBind<PS,SEG,S>
- All Known Implementing Classes:
CaretNode
public interface CaretAn object for encapsulating a caret in a given area."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:-
getPosition(), which refers to a position somewhere in the entire area's content. It's bounds are0 <= x <= area.getLength(). -
getColumnPosition(), which refers to a position somewhere in the current paragraph. It's bounds are0 <= x <= area.getParagraphLength(index).
"Line" refers either to a single paragraph when
the area does not wrap its textor to a line on a multi-line paragraph when the area does wrap its text.
-
-
Property Summary
Properties Type Property Description ObservableValue<Boolean>beingUpdatedObservableValue<Duration>blinkRateObservableValue<Optional<Bounds>>caretBoundsThe selectionBoundsProperty of the caret in the Screen's coordinate system orOptional.empty()if caret is not visible in the viewport.ObservableValue<Integer>columnPositionThe column position of the caret on its given lineObservableValue<OptionalInt>lineIndexThe line index of a multi-line paragraph that contains this caretObservableValue<Integer>paragraphIndexThe paragraph index that contains this caretObservableValue<Integer>positionThe position of the caret within the textVar<Caret.CaretVisibility>showCaretWhether to display the caret or not.ObservableValue<Boolean>visibleWhether the caret is being shown in the viewport
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classCaret.CaretVisibilityDetermines whether the caret is visible.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ObservableValue<Boolean>beingUpdatedProperty()ObservableValue<Duration>blinkRateProperty()ObservableValue<Optional<Bounds>>caretBoundsProperty()The selectionBoundsProperty of the caret in the Screen's coordinate system orOptional.empty()if caret is not visible in the viewport.voidclearTargetOffset()Clears the caret's x offsetObservableValue<Integer>columnPositionProperty()The column position of the caret on its given linevoiddispose()Disposes the caret and prevents memory leaksGenericStyledArea<?,?,?>getArea()Gets the area with which this caret is associated.DurationgetBlinkRate()Gets the value of the property blinkRate.Optional<Bounds>getCaretBounds()Gets the value of the property caretBounds.StringgetCaretName()Gets the name of this caret.intgetColumnPosition()Gets the value of the property columnPosition.OptionalIntgetLineIndex()Gets the value of the property lineIndex.intgetParagraphIndex()Gets the value of the property paragraphIndex.intgetPosition()Gets the value of the property position.Caret.CaretVisibilitygetShowCaret()Gets the value of the property showCaret.org.fxmisc.richtext.ParagraphBox.CaretOffsetXgetTargetOffset()Stores the caret's current column position, so that moving the caret vertically will keep it close to its original offset in a line.booleanisBeingUpdated()booleanisVisible()ObservableValue<OptionalInt>lineIndexProperty()The line index of a multi-line paragraph that contains this caretvoidmoveBreaksBackwards(int numOfBreaks, BreakIterator breakIterator)Moves the caret backwards by the number of breaks.voidmoveBreaksForwards(int numOfBreaks, BreakIterator breakIterator)Moves the caret forwards by the number of breaks.default voidmoveSentenceBreaksBackwards(int numOfSentenceBreaks)default voidmoveSentenceBreaksForwards(int numOfSentenceBreaks)voidmoveTo(int position)Moves the caret to the given position in the area.voidmoveTo(int paragraphIndex, int columnPosition)Moves the caret to the given position in the area.voidmoveToAreaEnd()Moves the caret to the end of the area.default voidmoveToAreaStart()Moves the caret to the beginning of the area.voidmoveToNextChar()Moves the caret forward one char in the text.voidmoveToParEnd()Moves the caret to the end of the current paragraph.voidmoveToParStart()Moves the caret to the beginning of the current paragraph.voidmoveToPrevChar()Moves the caret backward one char in the text.default voidmoveWordBreaksBackwards(int numOfWordBreaks)default voidmoveWordBreaksForwards(int numOfWordBreaks)ObservableValue<Integer>paragraphIndexProperty()The paragraph index that contains this caretObservableValue<Integer>positionProperty()The position of the caret within the textvoidsetBlinkRate(Duration blinkRate)Sets the value of the property blinkRate.voidsetShowCaret(Caret.CaretVisibility value)Sets the value of the property showCaret.Var<Caret.CaretVisibility>showCaretProperty()Whether to display the caret or not.ObservableValue<Boolean>visibleProperty()Whether the caret is being shown in the viewport
-
-
-
Property Detail
-
position
ObservableValue<Integer> positionProperty
The position of the caret within the text- See Also:
getPosition()
-
paragraphIndex
ObservableValue<Integer> paragraphIndexProperty
The paragraph index that contains this caret- See Also:
getParagraphIndex()
-
lineIndex
ObservableValue<OptionalInt> lineIndexProperty
The line index of a multi-line paragraph that contains this caret- See Also:
getLineIndex()
-
columnPosition
ObservableValue<Integer> columnPositionProperty
The column position of the caret on its given line- See Also:
getColumnPosition()
-
showCaret
Var<Caret.CaretVisibility> showCaretProperty
Whether to display the caret or not. Default value isCaret.CaretVisibility.AUTO.
-
visible
ObservableValue<Boolean> visibleProperty
Whether the caret is being shown in the viewport
-
blinkRate
ObservableValue<Duration> blinkRateProperty
- See Also:
getBlinkRate(),setBlinkRate(Duration)
-
caretBounds
ObservableValue<Optional<Bounds>> caretBoundsProperty
The selectionBoundsProperty of the caret in the Screen's coordinate system orOptional.empty()if caret is not visible in the viewport.- See Also:
getCaretBounds()
-
beingUpdated
ObservableValue<Boolean> beingUpdatedProperty
-
-
Method Detail
-
positionProperty
ObservableValue<Integer> positionProperty()
The position of the caret within the text- See Also:
getPosition()
-
getPosition
int getPosition()
Gets the value of the property position.- Property description:
- The position of the caret within the text
-
paragraphIndexProperty
ObservableValue<Integer> paragraphIndexProperty()
The paragraph index that contains this caret- See Also:
getParagraphIndex()
-
getParagraphIndex
int getParagraphIndex()
Gets the value of the property paragraphIndex.- Property description:
- The paragraph index that contains this caret
-
lineIndexProperty
ObservableValue<OptionalInt> lineIndexProperty()
The line index of a multi-line paragraph that contains this caret- See Also:
getLineIndex()
-
getLineIndex
OptionalInt getLineIndex()
Gets the value of the property lineIndex.- Property description:
- The line index of a multi-line paragraph that contains this caret
-
columnPositionProperty
ObservableValue<Integer> columnPositionProperty()
The column position of the caret on its given line- See Also:
getColumnPosition()
-
getColumnPosition
int getColumnPosition()
Gets the value of the property columnPosition.- Property description:
- The column position of the caret on its given line
-
showCaretProperty
Var<Caret.CaretVisibility> showCaretProperty()
Whether to display the caret or not. Default value isCaret.CaretVisibility.AUTO.
-
getShowCaret
Caret.CaretVisibility getShowCaret()
Gets the value of the property showCaret.- Property description:
- Whether to display the caret or not. Default value is
Caret.CaretVisibility.AUTO.
-
setShowCaret
void setShowCaret(Caret.CaretVisibility value)
Sets the value of the property showCaret.- Property description:
- Whether to display the caret or not. Default value is
Caret.CaretVisibility.AUTO.
-
visibleProperty
ObservableValue<Boolean> visibleProperty()
Whether the caret is being shown in the viewport
-
isVisible
boolean isVisible()
-
blinkRateProperty
ObservableValue<Duration> blinkRateProperty()
- See Also:
getBlinkRate(),setBlinkRate(Duration)
-
getBlinkRate
Duration getBlinkRate()
Gets the value of the property blinkRate.- Property description:
-
setBlinkRate
void setBlinkRate(Duration blinkRate)
Sets the value of the property blinkRate.- Property description:
-
caretBoundsProperty
ObservableValue<Optional<Bounds>> caretBoundsProperty()
The selectionBoundsProperty of the caret in the Screen's coordinate system orOptional.empty()if caret is not visible in the viewport.- See Also:
getCaretBounds()
-
getCaretBounds
Optional<Bounds> getCaretBounds()
Gets the value of the property caretBounds.- Property description:
- The selectionBoundsProperty of the caret in the Screen's coordinate system or
Optional.empty()if caret is not visible in the viewport.
-
clearTargetOffset
void clearTargetOffset()
Clears the caret's x offset
-
getTargetOffset
org.fxmisc.richtext.ParagraphBox.CaretOffsetX getTargetOffset()
Stores the caret's current column position, so that moving the caret vertically will keep it close to its original offset in a line.
-
isBeingUpdated
boolean isBeingUpdated()
-
beingUpdatedProperty
ObservableValue<Boolean> beingUpdatedProperty()
-
moveTo
void moveTo(int paragraphIndex, int columnPosition)Moves the caret to the given position in the area. If this caret is bound to aCaretSelectionBind, it displaces the caret from the selection by positioning only the caret to the new location without also affecting theCaretSelectionBind.getAnchorPosition()bounded selection's anchor} or theSelection.getRange()selection}.
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.Caution: see
TextEditingArea.getAbsolutePosition(int, int)to know how the column index argument can affect the returned position.
-
moveTo
void moveTo(int position)
Moves the caret to the given position in the area. If this caret is bound to aCaretSelectionBind, it displaces the caret from the selection by positioning only the caret to the new location without also affecting theCaretSelectionBind.getAnchorPosition()bounded selection's anchor} or theSelection.getRange()selection}.
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.
-
moveToParStart
void moveToParStart()
Moves the caret to the beginning of the current paragraph.
-
moveToParEnd
void moveToParEnd()
Moves the caret to the end of the current paragraph.
-
moveToAreaStart
default void moveToAreaStart()
Moves the caret to the beginning of the area.
-
moveToAreaEnd
void moveToAreaEnd()
Moves the caret to the end of the area.
-
moveToPrevChar
void moveToPrevChar()
Moves the caret backward one char in the text.
-
moveToNextChar
void moveToNextChar()
Moves the caret forward one char in the text.
-
moveBreaksForwards
void moveBreaksForwards(int numOfBreaks, BreakIterator breakIterator)Moves the caret forwards by the number of breaks.
-
moveWordBreaksForwards
default void moveWordBreaksForwards(int numOfWordBreaks)
-
moveSentenceBreaksForwards
default void moveSentenceBreaksForwards(int numOfSentenceBreaks)
-
moveBreaksBackwards
void moveBreaksBackwards(int numOfBreaks, BreakIterator breakIterator)Moves the caret backwards by the number of breaks.
-
moveWordBreaksBackwards
default void moveWordBreaksBackwards(int numOfWordBreaks)
-
moveSentenceBreaksBackwards
default void moveSentenceBreaksBackwards(int numOfSentenceBreaks)
-
dispose
void dispose()
Disposes the caret and prevents memory leaks
-
getArea
GenericStyledArea<?,?,?> getArea()
Gets the area with which this caret is associated.
-
getCaretName
String getCaretName()
Gets the name of this caret. Each caret that is added to an area must have a unique name since it is used to distinguish it from others in a Set.
-
-