TextSelection
A range of text that represents a selection.
Properties
-
affinity(TextAffinity) –If the text range is collapsed and has more than one visual location (e.g., occurs
-
base_offset(int) –The offset at which the selection originates.
-
directional(bool) –Whether this selection has disambiguated its base and extent.
-
end(int) –The next index after the characters in this range.
-
extent_offset(int) –The offset at which the selection terminates.
-
is_collapsed(bool) –Whether this range is empty (but still potentially placed inside the text).
-
is_normalized(bool) –Whether the start of this range precedes the end.
-
is_valid(bool) –Whether this range represents a valid position in the text.
-
start(int) –The index of the first character in the range.
Methods
-
get_selected_text–Returns the selected text from the given full text.
Properties#
affinity
class-attribute
instance-attribute
#
affinity: TextAffinity = DOWNSTREAM
If the text range is collapsed and has more than one visual location (e.g., occurs at a line break), which of the two locations to use when painting the caret.
directional
class-attribute
instance-attribute
#
directional: bool = False
Whether this selection has disambiguated its base and extent.
end
property
#
end: int
The next index after the characters in this range.
Note
This property is read-only.
is_collapsed
property
#
is_collapsed: bool
Whether this range is empty (but still potentially placed inside the text).
Note
This property is read-only.
is_normalized
property
#
is_normalized: bool
Whether the start of this range precedes the end.
Note
This property is read-only.
is_valid
property
#
is_valid: bool
Whether this range represents a valid position in the text.
Note
This property is read-only.
start
property
#
start: int
The index of the first character in the range.
Note
This property is read-only.