Spec-Zone.ru › OpenJavaFX 24

Interface SelectionModel

All Known Implementing Classes:
SingleSelectionModel
public interface SelectionModel
A Selection model that maintains a single SelectionSegment.
Since:
24

Property Summary

Type Property Description
ReadOnlyProperty<TextPos> anchorPosition
Anchor position property.
ReadOnlyProperty<TextPos> caretPosition
Caret position property.
ReadOnlyProperty<SelectionSegment> selection
Selection property.

Method Summary

Modifier and Type Method Description
ReadOnlyProperty<TextPos> anchorPositionProperty()
Anchor position property.
ReadOnlyProperty<TextPos> caretPositionProperty()
Caret position property.
void clear()
Clears the selection.
void extendSelection(StyledTextModel model, TextPos pos)
Extends selection to the specified position.
SelectionSegment getSelection()
Returns the current selection.
ReadOnlyProperty<SelectionSegment> selectionProperty()
Selection property.
void setSelection(StyledTextModel model, TextPos anchor, TextPos caret)
Replaced existing selection, if any, with the new one.

Property Details

caretPosition

ReadOnlyProperty<TextPos> caretPositionProperty
Caret position property. The value can be null, indicating no selection. When the caret position is null, the selectionProperty and the anchorPositionProperty are also null.

Note: selectionProperty(), anchorPositionProperty(), and caretPositionProperty() are logically connected. When a change occurs, the anchor position is updated first, followed by the caret position, followed by the selection segment.

Default value:
null
See Also:
  • caretPositionProperty()

anchorPosition

ReadOnlyProperty<TextPos> anchorPositionProperty
Anchor position property. The value can be null, indicating no selection. When the anchor position is null, the selectionProperty and the caretPositionProperty are also null.

Note: selectionProperty(), anchorPositionProperty(), and caretPositionProperty() are logically connected. When a change occurs, the anchor position is updated first, followed by the caret position, followed by the selection segment.

Default value:
null
See Also:
  • anchorPositionProperty()

selection

ReadOnlyProperty<SelectionSegment> selectionProperty
Selection property. The value can be null, indicating no selection. When the selection segment is null, the anchorPositionProperty and the caretPositionProperty are also null.
Default value:
null
See Also:
  • getSelection()
  • selectionProperty()

Method Details

clear

void clear()
Clears the selection. This sets selectionProperty, anchorPositionProperty, and caretPositionProperty to null.

setSelection

void setSelection(StyledTextModel model, TextPos anchor, TextPos caret)
Replaced existing selection, if any, with the new one. While this method will accept the text positions outside of the document range, the actual values of anchorPositionProperty, and caretPositionProperty must always remain within the valid range for the document.
Parameters:
model - the model, must be non-null
anchor - the anchor position, must be non-null
caret - the caret position, must be non-null

extendSelection

void extendSelection(StyledTextModel model, TextPos pos)
Extends selection to the specified position. Internally, the position will be normalized to be within the document boundaries. This method will issue a setSelection(model, pos, pos) call if the model instance is different from that passed before.

While this method will accept the text position outside of the document range, the actual values of anchorPositionProperty, and caretPositionProperty must always remain within the valid range for the document.

Parameters:
model - the model, must be non-null
pos - the new caret position, must be non-null

caretPositionProperty

ReadOnlyProperty<TextPos> caretPositionProperty()
Caret position property. The value can be null, indicating no selection. When the caret position is null, the selectionProperty and the anchorPositionProperty are also null.

Note: selectionProperty(), anchorPositionProperty(), and caretPositionProperty() are logically connected. When a change occurs, the anchor position is updated first, followed by the caret position, followed by the selection segment.

Default value:
null
Returns:
the caret position property

anchorPositionProperty

ReadOnlyProperty<TextPos> anchorPositionProperty()
Anchor position property. The value can be null, indicating no selection. When the anchor position is null, the selectionProperty and the caretPositionProperty are also null.

Note: selectionProperty(), anchorPositionProperty(), and caretPositionProperty() are logically connected. When a change occurs, the anchor position is updated first, followed by the caret position, followed by the selection segment.

Default value:
null
Returns:
the anchor position property

selectionProperty

ReadOnlyProperty<SelectionSegment> selectionProperty()
Selection property. The value can be null, indicating no selection. When the selection segment is null, the anchorPositionProperty and the caretPositionProperty are also null.
Default value:
null
Returns:
the selection property
See Also:
  • getSelection()

getSelection

SelectionSegment getSelection()
Returns the current selection. The value can be null, indicating no selection. When the selection segment is null, the anchorPositionProperty and the caretPositionProperty are also null.
Returns:
current selection, or null

Report a bug or suggest an enhancement
Copyright © 2008, 2025, Oracle and/or its affiliates. All rights reserved.

© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API