pub struct StringGuard<A> { /* private fields */ }
Expand description

An EditGuard for read-only strings

This may be used with read-only edit fields, essentially resulting in a fancier version of Text or ScrollText.

Implementations§

source§

impl<A> StringGuard<A>

source

pub fn new(value_fn: impl Fn(&A) -> String + 'static) -> Self

Construct with a value function

On update, value_fn is used to extract a value from input data. If, however, the input field has focus, the update is ignored.

No other action happens unless Self::with_msg is used.

source

pub fn with(self, f: impl Fn(&mut EventCx<'_>, &A, &str) + 'static) -> Self

Call the handler f on activation / focus loss

On field activation and focus loss (AFL) after an edit, f is called.

source

pub fn with_msg<M: Debug + 'static>( self, f: impl Fn(&str) -> M + 'static ) -> Self

Send the message generated by f on activation / focus loss

On field activation and focus loss (AFL) after an edit, f is used to construct a message to be emitted via EventCx::push.

Trait Implementations§

source§

impl<A> Debug for StringGuard<A>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<A> EditGuard for StringGuard<A>

§

type Data = A

Data type
source§

fn focus_lost(edit: &mut EditField<Self>, cx: &mut EventCx<'_>, data: &A)

Focus-lost guard Read more
source§

fn update(edit: &mut EditField<Self>, cx: &mut ConfigCx<'_>, data: &A)

Update guard Read more
source§

fn edit(edit: &mut EditField<Self>, _: &mut EventCx<'_>, _: &Self::Data)

Edit guard Read more
source§

fn configure(edit: &mut EditField<Self>, cx: &mut ConfigCx<'_>)

Configure guard Read more
source§

fn activate( edit: &mut EditField<Self>, cx: &mut EventCx<'_>, data: &Self::Data ) -> IsUsed

Activation guard Read more
source§

fn focus_gained( edit: &mut EditField<Self>, cx: &mut EventCx<'_>, data: &Self::Data )

Focus-gained guard Read more

Auto Trait Implementations§

§

impl<A> !RefUnwindSafe for StringGuard<A>

§

impl<A> !Send for StringGuard<A>

§

impl<A> !Sync for StringGuard<A>

§

impl<A> Unpin for StringGuard<A>

§

impl<A> !UnwindSafe for StringGuard<A>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<S, T> Cast<T> for S
where T: Conv<S>,

§

fn cast(self) -> T

Cast from Self to T Read more
§

fn try_cast(self) -> Result<T, Error>

Try converting from Self to T Read more
§

impl<S, T> CastApprox<T> for S
where T: ConvApprox<S>,

§

fn try_cast_approx(self) -> Result<T, Error>

Try approximate conversion from Self to T Read more
§

fn cast_approx(self) -> T

Cast approximately from Self to T Read more
§

impl<S, T> CastFloat<T> for S
where T: ConvFloat<S>,

§

fn cast_trunc(self) -> T

Cast to integer, truncating Read more
§

fn cast_nearest(self) -> T

Cast to the nearest integer Read more
§

fn cast_floor(self) -> T

Cast the floor to an integer Read more
§

fn cast_ceil(self) -> T

Cast the ceiling to an integer Read more
§

fn try_cast_trunc(self) -> Result<T, Error>

Try converting to integer with truncation Read more
§

fn try_cast_nearest(self) -> Result<T, Error>

Try converting to the nearest integer Read more
§

fn try_cast_floor(self) -> Result<T, Error>

Try converting the floor to an integer Read more
§

fn try_cast_ceil(self) -> Result<T, Error>

Try convert the ceiling to an integer Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more