pub struct TextEditingController { /* private fields */ }Expand description
Cloneable editing controller. It owns no platform resources; platform and widget layers can subscribe to value changes and decide when to repaint.
Implementations§
Source§impl TextEditingController
impl TextEditingController
pub fn new() -> Self
Sourcepub fn with_text(text: impl Into<String>) -> Self
pub fn with_text(text: impl Into<String>) -> Self
Creates a controller initialized with committed text.
Sourcepub fn restored(scope: RestorationScope, key: RestorationKey) -> Self
pub fn restored(scope: RestorationScope, key: RestorationKey) -> Self
Creates an empty editor and restores its committed state, if present.
Sourcepub fn bind_restoration(&self, scope: RestorationScope, key: RestorationKey)
pub fn bind_restoration(&self, scope: RestorationScope, key: RestorationKey)
Binds committed text and selection to a stable restoration value.
Sourcepub fn unbind_restoration(&self)
pub fn unbind_restoration(&self)
Stops persisting subsequent editor mutations without deleting the saved value.
pub fn from_value(value: TextEditingValue) -> Self
pub fn value(&self) -> TextEditingValue
pub fn text(&self) -> String
pub fn selection(&self) -> TextSelection
pub fn composing(&self) -> Option<ComposingRange>
pub fn set_value(&self, value: TextEditingValue)
pub fn set_text(&self, text: impl Into<String>)
pub fn clear(&self)
pub fn set_selection(&self, selection: TextSelection)
Sourcepub fn set_selection_with_affinity(
&self,
selection: TextSelection,
affinity: TextAffinity,
)
pub fn set_selection_with_affinity( &self, selection: TextSelection, affinity: TextAffinity, )
Sets a selection while preserving which visual edge of a bidi run owns a collapsed caret. Native hit testing should use this overload.
pub fn set_composing(&self, composing: Option<ComposingRange>)
Sourcepub fn observe(
&self,
listener: impl Fn(&TextEditingValue) + 'static,
) -> TextEditingSubscription
pub fn observe( &self, listener: impl Fn(&TextEditingValue) + 'static, ) -> TextEditingSubscription
Observes committed editing changes with automatic cleanup on drop.
Sourcepub fn add_listener(
&self,
listener: impl Fn(&TextEditingValue) + 'static,
) -> usize
pub fn add_listener( &self, listener: impl Fn(&TextEditingValue) + 'static, ) -> usize
Low-level manual registration for backend integrations. Prefer observe.
Returns an opaque token accepted by
Self::remove_listener.
pub fn remove_listener(&self, token: usize) -> bool
pub fn apply_delta(&self, delta: &TextEditingDelta)
pub fn replace_selection(&self, replacement: &str)
pub fn insert_text(&self, text: &str)
pub fn delete_backward(&self)
pub fn delete_forward(&self)
Sourcepub fn backspace(&self)
pub fn backspace(&self)
Deletes one grapheme cluster behind the caret, or the active selection.
pub fn move_left(&self, extend: bool)
pub fn move_right(&self, extend: bool)
Sourcepub fn move_left_visual(&self, layout: &TextLayout, extend: bool)
pub fn move_left_visual(&self, layout: &TextLayout, extend: bool)
Moves one grapheme in screen/visual order using the bidi caret stops
emitted by TextLayout. The logical byte offset may move backwards
while the caret moves right, which is required for right-to-left text.
Sourcepub fn move_right_visual(&self, layout: &TextLayout, extend: bool)
pub fn move_right_visual(&self, layout: &TextLayout, extend: bool)
Moves one grapheme in screen/visual order using the bidi caret stops
emitted by TextLayout.
pub fn move_home(&self, extend: bool)
pub fn move_end(&self, extend: bool)
pub fn select_all(&self)
pub fn selected_text(&self) -> String
Sourcepub fn set_preedit(&self, text: impl Into<String>, selection: Option<TextRange>)
pub fn set_preedit(&self, text: impl Into<String>, selection: Option<TextRange>)
Sets transient IME preedit text without changing committed content.
pub fn commit_preedit(&self, text: &str)
pub fn clear_preedit(&self)
pub fn preedit(&self) -> Option<String>
pub fn preedit_selection(&self) -> Option<TextRange>
Sourcepub fn caret_affinity(&self) -> TextAffinity
pub fn caret_affinity(&self) -> TextAffinity
Returns the visual affinity of the collapsed caret.
Trait Implementations§
Source§impl Clone for TextEditingController
impl Clone for TextEditingController
Source§impl Debug for TextEditingController
impl Debug for TextEditingController
Source§impl Default for TextEditingController
impl Default for TextEditingController
Auto Trait Implementations§
impl !RefUnwindSafe for TextEditingController
impl !Send for TextEditingController
impl !Sync for TextEditingController
impl !UnwindSafe for TextEditingController
impl Freeze for TextEditingController
impl Unpin for TextEditingController
impl UnsafeUnpin for TextEditingController
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
replaced by palette::chromatic_adaptation::AdaptIntoUnclamped
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
replaced by palette::chromatic_adaptation::AdaptIntoUnclamped
Source§impl<T, C> AdaptIntoUnclamped<T> for Cwhere
T: AdaptFromUnclamped<C>,
impl<T, C> AdaptIntoUnclamped<T> for Cwhere
T: AdaptFromUnclamped<C>,
Source§type Scalar = <T as AdaptFromUnclamped<C>>::Scalar
type Scalar = <T as AdaptFromUnclamped<C>>::Scalar
Source§fn adapt_into_unclamped_with<M>(self) -> Twhere
M: LmsToXyz<<C as AdaptIntoUnclamped<T>>::Scalar> + XyzToLms<<C as AdaptIntoUnclamped<T>>::Scalar>,
fn adapt_into_unclamped_with<M>(self) -> Twhere
M: LmsToXyz<<C as AdaptIntoUnclamped<T>>::Scalar> + XyzToLms<<C as AdaptIntoUnclamped<T>>::Scalar>,
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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
impl<T> Brush for T
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T, C> ComponentsInto<C> for T
impl<T, C> ComponentsInto<C> for T
Source§fn components_into(self) -> C
fn components_into(self) -> C
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more