TextSelection
A range of text that represents a selection.
Properties
affinity- 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.base_offset- The offset at which the selection originates.directional- Whether this selection has disambiguated its base and extent.end- The next index after the characters in this range.extent_offset- The offset at which the selection terminates.is_collapsed- Whether this range is empty (but still potentially placed inside the text).is_normalized- Whether the start of this range precedes the end.is_valid- Whether this range represents a valid position in the text.start- The index of the first character in the range.
Methods
get_selected_text- Returns the selected text from the given full text.
Properties
affinityclass-attributeinstance-attribute
affinity: TextAffinity = TextAffinity.DOWNSTREAMIf 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.
directionalclass-attributeinstance-attribute
directional: bool = FalseWhether this selection has disambiguated its base and extent.
endproperty
end: intThe next index after the characters in this range.
Note
This property is read-only.
is_collapsedproperty
is_collapsed: boolWhether this range is empty (but still potentially placed inside the text).
Note
This property is read-only.
is_normalizedproperty
is_normalized: boolWhether the start of this range precedes the end.
Note
This property is read-only.
is_validproperty
is_valid: boolWhether this range represents a valid position in the text.
Note
This property is read-only.
startproperty
start: intThe index of the first character in the range.
Note
This property is read-only.