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§
source§impl 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§
source§impl Clone for EventListenerOptions
impl Clone for EventListenerOptions
source§fn clone(&self) -> EventListenerOptions
fn clone(&self) -> EventListenerOptions
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for EventListenerOptions
impl Debug for EventListenerOptions
source§impl Default for EventListenerOptions
impl Default for EventListenerOptions
source§impl PartialEq<EventListenerOptions> for EventListenerOptions
impl PartialEq<EventListenerOptions> for EventListenerOptions
source§fn eq(&self, other: &EventListenerOptions) -> bool
fn eq(&self, other: &EventListenerOptions) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Copy for EventListenerOptions
impl Eq for EventListenerOptions
impl StructuralEq for EventListenerOptions
impl StructuralPartialEq 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§
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