pub struct InputOtpState { /* private fields */ }Expand description
One ASCII-digit code, backed by the same editor as Input.
Paste, selection, navigation, undo, deletion, IME and native accessibility belong to that editor. A paste is accepted only when its entire resulting value is numeric and fits the slots; excess text is never silently dropped. The component does not send or verify codes.
Implementations§
Source§impl InputOtpState
impl InputOtpState
Sourcepub fn new(
length: usize,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> Self
pub fn new( length: usize, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Self
Creates a fixed number of digit slots. length must be nonzero.
pub fn length(&self) -> usize
pub fn value(&self, cx: &App) -> SharedString
pub fn is_complete(&self, cx: &App) -> bool
pub fn focus_handle(&self, cx: &App) -> FocusHandle
Sourcepub fn input(&self) -> &Entity<InputState>
pub fn input(&self) -> &Entity<InputState>
Access to the existing editor for selection, focus, native text input
integration and InputEvent::PressEnter subscriptions. Keep its numeric
validator intact; change the code through Self::set_value.
Sourcepub fn set_value(
&mut self,
value: impl Into<SharedString>,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> bool
pub fn set_value( &mut self, value: impl Into<SharedString>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> bool
Replaces the code without emitting a user edit or preserving undo. Returns false for non-ASCII digits or a value longer than the slots.
pub fn set_disabled(&mut self, disabled: bool, cx: &mut Context<'_, Self>)
pub fn set_readonly(&mut self, readonly: bool, cx: &mut Context<'_, Self>)
Trait Implementations§
impl EventEmitter<InputOtpEvent> for InputOtpState
Auto Trait Implementations§
impl !RefUnwindSafe for InputOtpState
impl !Send for InputOtpState
impl !Sync for InputOtpState
impl !UnwindSafe for InputOtpState
impl Forget for InputOtpState
impl Freeze for InputOtpStatewhere
NonZero<u32>: Freeze,
*const (): Freeze,
*const ArcInner<RwLock<RawRwLock, EntityRefCounts>> is !null: Freeze,
PhantomData<fn(InputBaseState<InputMode>) -> InputBaseState<InputMode>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<Subscription>: Freeze,
impl Move for InputOtpState
impl Unpin for InputOtpState
impl UnsafeUnpin for InputOtpStatewhere
NonZeroU32Inner: UnsafeUnpin,
*const (): UnsafeUnpin,
*const ArcInner<RwLock<RawRwLock, EntityRefCounts>> is !null: UnsafeUnpin,
PhantomData<fn(InputBaseState<InputMode>) -> InputBaseState<InputMode>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<Subscription>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
Converts
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> ⓘ
Converts
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 more