pub struct BeforeInputData { /* private fields */ }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) -> Self
pub fn new(inner: impl HasBeforeInputData + 'static) -> Self
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.