pub enum AnyInputState {
Input(Entity<InputState>),
Textarea(Entity<TextareaState>),
Editor(Entity<EditorState>),
Otp(Entity<OtpState>),
}Expand description
Any input-like state, regardless of which input element renders it.
InputState, TextareaState, EditorState and OtpState are
separate types, so an API that refers to “whatever input is here” takes this
enum instead of one of them. crate::WindowExt::focused_input returns it.
Use Self::as_input and friends to get the concrete state back, or
Self::value and Self::focus_handle when the kind does not matter.
Variants§
Input(Entity<InputState>)
A single-line crate::input::Input state.
Textarea(Entity<TextareaState>)
A multi-line crate::input::Textarea state.
Editor(Entity<EditorState>)
A source-code crate::input::Editor state.
Otp(Entity<OtpState>)
A one-time-code crate::input::OtpInput state.
Implementations§
Source§impl AnyInputState
impl AnyInputState
Sourcepub fn as_input(&self) -> Option<&Entity<InputState>>
pub fn as_input(&self) -> Option<&Entity<InputState>>
Returns the InputState, if this is an Input state.
Sourcepub fn as_textarea(&self) -> Option<&Entity<TextareaState>>
pub fn as_textarea(&self) -> Option<&Entity<TextareaState>>
Returns the TextareaState, if this is a Textarea state.
Sourcepub fn as_editor(&self) -> Option<&Entity<EditorState>>
pub fn as_editor(&self) -> Option<&Entity<EditorState>>
Returns the EditorState, if this is an Editor state.
Sourcepub fn as_otp(&self) -> Option<&Entity<OtpState>>
pub fn as_otp(&self) -> Option<&Entity<OtpState>>
Returns the OtpState, if this is an OtpInput state.
Sourcepub fn value(&self, cx: &App) -> SharedString
pub fn value(&self, cx: &App) -> SharedString
Returns the value of the input.
A masked input returns its masked value, the same as what is rendered.
Sourcepub fn focus_handle(&self, cx: &App) -> FocusHandle
pub fn focus_handle(&self, cx: &App) -> FocusHandle
Returns the focus handle of the input.
Trait Implementations§
Source§impl Clone for AnyInputState
impl Clone for AnyInputState
Source§fn clone(&self) -> AnyInputState
fn clone(&self) -> AnyInputState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AnyInputState
impl Debug for AnyInputState
impl Eq for AnyInputState
Source§impl From<Entity<InputBaseState<EditorMode>>> for AnyInputState
impl From<Entity<InputBaseState<EditorMode>>> for AnyInputState
Source§fn from(state: Entity<EditorState>) -> Self
fn from(state: Entity<EditorState>) -> Self
Source§impl From<Entity<InputBaseState<InputMode>>> for AnyInputState
impl From<Entity<InputBaseState<InputMode>>> for AnyInputState
Source§fn from(state: Entity<InputState>) -> Self
fn from(state: Entity<InputState>) -> Self
Source§impl From<Entity<InputBaseState<TextareaMode>>> for AnyInputState
impl From<Entity<InputBaseState<TextareaMode>>> for AnyInputState
Source§fn from(state: Entity<TextareaState>) -> Self
fn from(state: Entity<TextareaState>) -> Self
Source§impl PartialEq for AnyInputState
impl PartialEq for AnyInputState
impl StructuralPartialEq for AnyInputState
Auto Trait Implementations§
impl !RefUnwindSafe for AnyInputState
impl !UnwindSafe for AnyInputState
impl Freeze for AnyInputState
impl Send for AnyInputState
impl Sync for AnyInputState
impl Unpin for AnyInputState
impl UnsafeUnpin for AnyInputState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> ⓘ
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 more