Top Description Inners Methods
org.fxmisc.richtext

public Interface Caret

Known Direct Subinterfaces
org.fxmisc.richtext.CaretSelectionBind
Known Direct Implementers
org.fxmisc.richtext.CaretNode
Imports
javafx.beans.value.ObservableValue, javafx.geometry.Bounds, javafx.util.Duration, org.reactfx.value.Var, java.text.BreakIterator, java.util.Optional, .OptionalInt

An 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:

  1. getPosition(), which refers to a position somewhere in the entire area's content. It's bounds are 0 <= x <= area.getLength().
  2. getColumnPosition(), 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.

"Line" refers either to a single paragraph when the area does not wrap its text or to a line on a multi-line paragraph when the area does wrap its text.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Caret.CaretVisibility

Determines whether the caret is visible.

Method Summary

Modifier and TypeMethod and Description
public ObservableValue<Boolean>
public ObservableValue<Duration>
public ObservableValue<Optional<Bounds>>
caretBoundsProperty()

The selectionBoundsProperty of the caret in the Screen's coordinate system or Optional#empty() if caret is not visible in the viewport.

public void
clearTargetOffset()

Clears the caret's x offset

public ObservableValue<Integer>
columnPositionProperty()

The column position of the caret on its given line

public void
dispose()

Disposes the caret and prevents memory leaks

public GenericStyledArea<?, ?, ?>
getArea()

Gets the area with which this caret is associated.

public Duration
public Optional<Bounds>
public String
getCaretName()

Gets the name of this caret.

public int
public OptionalInt
public int
public int
public Caret.CaretVisibility
public 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.

public boolean
public boolean
public ObservableValue<OptionalInt>
lineIndexProperty()

The line index of a multi-line paragraph that contains this caret

public void
moveBreaksBackwards(int numOfBreaks, BreakIterator breakIterator)

Moves the caret backwards by the number of breaks.

public void
moveBreaksForwards(int numOfBreaks, BreakIterator breakIterator)

Moves the caret forwards by the number of breaks.

public default void
moveSentenceBreaksBackwards(int numOfSentenceBreaks)

public default void
moveSentenceBreaksForwards(int numOfSentenceBreaks)

public void
moveTo(int paragraphIndex, int columnPosition)

Moves the caret to the given position in the area.

public void
moveTo(int position)

Moves the caret to the given position in the area.

public void
moveToAreaEnd()

Moves the caret to the end of the area.

public default void
moveToAreaStart()

Moves the caret to the beginning of the area.

public void
moveToNextChar()

Moves the caret forward one char in the text.

public void
moveToParEnd()

Moves the caret to the end of the current paragraph.

public void
moveToParStart()

Moves the caret to the beginning of the current paragraph.

public void
moveToPrevChar()

Moves the caret backward one char in the text.

public default void
moveWordBreaksBackwards(int numOfWordBreaks)

public default void
moveWordBreaksForwards(int numOfWordBreaks)

public ObservableValue<Integer>
paragraphIndexProperty()

The paragraph index that contains this caret

public ObservableValue<Integer>
positionProperty()

The position of the caret within the text

public void
public void
public Var<Caret.CaretVisibility>
showCaretProperty()

Whether to display the caret or not.

public ObservableValue<Boolean>
visibleProperty()

Whether the caret is being shown in the viewport

Method Detail

beingUpdatedPropertyback to summary
public ObservableValue<Boolean> beingUpdatedProperty()
blinkRatePropertyback to summary
public ObservableValue<Duration> blinkRateProperty()
caretBoundsPropertyback to summary
public ObservableValue<Optional<Bounds>> caretBoundsProperty()

The selectionBoundsProperty of the caret in the Screen's coordinate system or Optional#empty() if caret is not visible in the viewport.

clearTargetOffsetback to summary
public void clearTargetOffset()

Clears the caret's x offset

columnPositionPropertyback to summary
public ObservableValue<Integer> columnPositionProperty()

The column position of the caret on its given line

disposeback to summary
public void dispose()

Disposes the caret and prevents memory leaks

getAreaback to summary
public GenericStyledArea<?, ?, ?> getArea()

Gets the area with which this caret is associated.

getBlinkRateback to summary
public Duration getBlinkRate()
getCaretBoundsback to summary
public Optional<Bounds> getCaretBounds()
getCaretNameback to summary
public 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.

getColumnPositionback to summary
public int getColumnPosition()
getLineIndexback to summary
public OptionalInt getLineIndex()
getParagraphIndexback to summary
public int getParagraphIndex()
getPositionback to summary
public int getPosition()
getShowCaretback to summary
public Caret.CaretVisibility getShowCaret()
getTargetOffsetback to summary
public 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.

isBeingUpdatedback to summary
public boolean isBeingUpdated()
isVisibleback to summary
public boolean isVisible()
lineIndexPropertyback to summary
public ObservableValue<OptionalInt> lineIndexProperty()

The line index of a multi-line paragraph that contains this caret

moveBreaksBackwardsback to summary
public void moveBreaksBackwards(int numOfBreaks, BreakIterator breakIterator)

Moves the caret backwards by the number of breaks.

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

Moves the caret forwards by the number of breaks.

moveSentenceBreaksBackwardsback to summary
public default void moveSentenceBreaksBackwards(int numOfSentenceBreaks)
moveSentenceBreaksForwardsback to summary
public default void moveSentenceBreaksForwards(int numOfSentenceBreaks)
moveToback to summary
public void moveTo(int paragraphIndex, int columnPosition)

Moves the caret to the given position in the area. If this caret is bound to a CaretSelectionBind, it displaces the caret from the selection by positioning only the caret to the new location without also affecting the CaretSelectionBind#getAnchorPosition() bounded selection's anchor} or the CaretSelectionBind#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.

moveToback to summary
public void moveTo(int position)

Moves the caret to the given position in the area. If this caret is bound to a CaretSelectionBind, it displaces the caret from the selection by positioning only the caret to the new location without also affecting the CaretSelectionBind#getAnchorPosition() bounded selection's anchor} or the CaretSelectionBind#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.

moveToAreaEndback to summary
public void moveToAreaEnd()

Moves the caret to the end of the area.

moveToAreaStartback to summary
public default void moveToAreaStart()

Moves the caret to the beginning of the area.

moveToNextCharback to summary
public void moveToNextChar()

Moves the caret forward one char in the text.

moveToParEndback to summary
public void moveToParEnd()

Moves the caret to the end of the current paragraph.

moveToParStartback to summary
public void moveToParStart()

Moves the caret to the beginning of the current paragraph.

moveToPrevCharback to summary
public void moveToPrevChar()

Moves the caret backward one char in the text.

moveWordBreaksBackwardsback to summary
public default void moveWordBreaksBackwards(int numOfWordBreaks)
moveWordBreaksForwardsback to summary
public default void moveWordBreaksForwards(int numOfWordBreaks)
paragraphIndexPropertyback to summary
public ObservableValue<Integer> paragraphIndexProperty()

The paragraph index that contains this caret

positionPropertyback to summary
public ObservableValue<Integer> positionProperty()

The position of the caret within the text

setBlinkRateback to summary
public void setBlinkRate(Duration blinkRate)
setShowCaretback to summary
public void setShowCaret(Caret.CaretVisibility value)
showCaretPropertyback to summary
public Var<Caret.CaretVisibility> showCaretProperty()

Whether to display the caret or not. Default value is CaretVisibility#AUTO.

visiblePropertyback to summary
public ObservableValue<Boolean> visibleProperty()

Whether the caret is being shown in the viewport

org.fxmisc.richtext back to summary

public final Enum Caret.CaretVisibility

extends Enum<Caret.CaretVisibility>
Class Inheritance

Determines whether the caret is visible. Those who wish to use the default configuration should use AUTO while those who want a more custom configuration should make a caret's CaretVisibility value oscillate between ON and OFF.

Field Summary

Modifier and TypeField and Description
public static final Caret.CaretVisibility
AUTO

Caret is displayed when area is focused, enabled, and editable.

public static final Caret.CaretVisibility
OFF

Caret is not displayed.

public static final Caret.CaretVisibility
ON

Caret is displayed.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Caret.CaretVisibility
public static Caret.CaretVisibility[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

AUTOback to summary
public static final Caret.CaretVisibility AUTO

Caret is displayed when area is focused, enabled, and editable.

OFFback to summary
public static final Caret.CaretVisibility OFF

Caret is not displayed.

ONback to summary
public static final Caret.CaretVisibility ON

Caret is displayed.

Constructor Detail

CaretVisibilityback to summary
private CaretVisibility()

Method Detail

valueOfback to summary
public static Caret.CaretVisibility valueOf(String name)
valuesback to summary
public static Caret.CaretVisibility[] values()