pub struct BeforeInputData { /* private fields */ }prelude only.Expand description
Data fired alongside the beforeinput event.
The beforeinput event fires before an editable element (an <input>, <textarea>,
or any element with contenteditable="true") is about to be modified. It exposes
the kind of mutation that is about to happen via BeforeInputData::input_type
and the text that is about to be inserted (if any) via BeforeInputData::data.
Unlike input, beforeinput is cancellable: calling event.prevent_default()
from the handler will block the user-agent from applying the change.
See https://developer.mozilla.org/en-US/docs/Web/API/Element/beforeinput_event for the underlying DOM event.
Implementations§
Source§impl BeforeInputData
impl BeforeInputData
Sourcepub fn new(inner: impl HasBeforeInputData + 'static) -> BeforeInputData
pub fn new(inner: impl HasBeforeInputData + 'static) -> BeforeInputData
Create a new BeforeInputData from any HasBeforeInputData implementation.
Sourcepub fn input_type(&self) -> InputType
pub fn input_type(&self) -> InputType
The type of change that is about to be applied to the editable element.
Returns an InputType so the common cases (e.g. InputType::InsertText,
InputType::DeleteContentBackward) can be matched on directly. Values not
covered by a known variant are preserved in InputType::Unknown. The full
list is documented at
https://w3c.github.io/input-events/#interface-InputEvent-Attributes.
Sourcepub fn data(&self) -> Option<String>
pub fn data(&self) -> Option<String>
The characters that are about to be inserted by the user agent, if any.
None is returned for input types that don’t carry text data, e.g. deletions
or rich-text formatting changes.
Sourcepub fn is_composing(&self) -> bool
pub fn is_composing(&self) -> bool
Whether the event was fired while an IME composition session is active.
Trait Implementations§
Source§impl Debug for BeforeInputData
impl Debug for BeforeInputData
Source§impl From<&PlatformEventData> for BeforeInputData
impl From<&PlatformEventData> for BeforeInputData
Source§fn from(val: &PlatformEventData) -> BeforeInputData
fn from(val: &PlatformEventData) -> BeforeInputData
Source§impl<E> From<E> for BeforeInputDatawhere
E: HasBeforeInputData,
impl<E> From<E> for BeforeInputDatawhere
E: HasBeforeInputData,
Source§fn from(e: E) -> BeforeInputData
fn from(e: E) -> BeforeInputData
Auto Trait Implementations§
impl !RefUnwindSafe for BeforeInputData
impl !Send for BeforeInputData
impl !Sync for BeforeInputData
impl !UnwindSafe for BeforeInputData
impl Freeze for BeforeInputData
impl Unpin for BeforeInputData
impl UnsafeUnpin for BeforeInputData
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
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