Struct gloo_events::EventListenerOptions
source · [−]pub struct EventListenerOptions {
pub phase: EventListenerPhase,
pub passive: bool,
}
Expand description
Specifies options for EventListener::new_with_options
and
EventListener::once_with_options
.
Default
EventListenerOptions {
phase: EventListenerPhase::Bubble,
passive: true,
}
Examples
Sets phase
to EventListenerPhase::Capture
, using the default for the rest:
let options = EventListenerOptions::run_in_capture_phase();
Sets passive
to false
, using the default for the rest:
let options = EventListenerOptions::enable_prevent_default();
Specifies all options:
let options = EventListenerOptions {
phase: EventListenerPhase::Capture,
passive: false,
};
Fields
phase: EventListenerPhase
The phase that the event listener should be run in.
passive: bool
If this is true
then performance is improved, but it is not possible to use
event.prevent_default()
.
If this is false
then performance might be reduced, but now it is possible to use
event.prevent_default()
.
You can read more about the performance costs here.
Implementations
sourceimpl EventListenerOptions
impl EventListenerOptions
sourcepub fn run_in_capture_phase() -> Self
pub fn run_in_capture_phase() -> Self
Returns an EventListenerOptions
with phase
set to EventListenerPhase::Capture
.
This is the same as:
EventListenerOptions {
phase: EventListenerPhase::Capture,
..Default::default()
}
sourcepub fn enable_prevent_default() -> Self
pub fn enable_prevent_default() -> Self
Returns an EventListenerOptions
with passive
set to false
.
This is the same as:
EventListenerOptions {
passive: false,
..Default::default()
}
Trait Implementations
sourceimpl Clone for EventListenerOptions
impl Clone for EventListenerOptions
sourcefn clone(&self) -> EventListenerOptions
fn clone(&self) -> EventListenerOptions
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for EventListenerOptions
impl Debug for EventListenerOptions
sourceimpl Default for EventListenerOptions
impl Default for EventListenerOptions
impl Copy for EventListenerOptions
Auto Trait Implementations
impl RefUnwindSafe for EventListenerOptions
impl Send for EventListenerOptions
impl Sync for EventListenerOptions
impl Unpin for EventListenerOptions
impl UnwindSafe for EventListenerOptions
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more