pub struct TextFieldValue {
pub annotated_string: AnnotatedString,
pub selection: TextRange,
pub composition: Option<TextRange>,
}Expand description
Snapshot of a text field’s editing state including text, selection, and
IME composition range. Corresponds to Compose’s TextFieldValue.
Fields§
§annotated_string: AnnotatedStringThe annotated text. Plain text is accessible via text() or annotated_string.text.
selection: TextRangeSelection range in byte offsets. Collapsed range (start == end) = cursor.
composition: Option<TextRange>Active IME composition range in byte offsets, or None.
Implementations§
Source§impl TextFieldValue
impl TextFieldValue
Sourcepub fn from_annotated(annotated: AnnotatedString) -> Self
pub fn from_annotated(annotated: AnnotatedString) -> Self
Create from an AnnotatedString preserving all annotations.
Sourcepub fn text(&self) -> &str
pub fn text(&self) -> &str
Convenience: plain text content (delegates to annotated_string.text).
pub fn with_selection(self, start: usize, end: usize) -> Self
pub fn get_text_before_selection(&self, max_chars: usize) -> AnnotatedString
pub fn get_text_after_selection(&self, max_chars: usize) -> AnnotatedString
pub fn get_selected_text(&self) -> AnnotatedString
Sourcepub fn copy(&self, annotated_string: AnnotatedString) -> Self
pub fn copy(&self, annotated_string: AnnotatedString) -> Self
Returns a copy with the given annotated string.
Trait Implementations§
Source§impl Clone for TextFieldValue
impl Clone for TextFieldValue
Source§fn clone(&self) -> TextFieldValue
fn clone(&self) -> TextFieldValue
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TextFieldValue
impl Debug for TextFieldValue
Source§impl PartialEq for TextFieldValue
impl PartialEq for TextFieldValue
Source§fn eq(&self, other: &TextFieldValue) -> bool
fn eq(&self, other: &TextFieldValue) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for TextFieldValue
Auto Trait Implementations§
impl Freeze for TextFieldValue
impl RefUnwindSafe for TextFieldValue
impl Send for TextFieldValue
impl Sync for TextFieldValue
impl Unpin for TextFieldValue
impl UnsafeUnpin for TextFieldValue
impl UnwindSafe for TextFieldValue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more