pub struct Event {Show 15 fields
pub event_type: EventType,
pub target: NodeId,
pub current_target: NodeId,
pub phase: EventPhase,
pub bubbles: bool,
pub cancelable: bool,
pub default_prevented: bool,
pub propagation_stopped: bool,
pub immediate_propagation_stopped: bool,
pub mouse_x: i32,
pub mouse_y: i32,
pub button: u8,
pub key_code: u32,
pub char_code: u32,
pub modifiers: u8,
}Expand description
A DOM event
Fields§
§event_type: EventTypeType of the event
target: NodeIdTarget node (the node the event was dispatched on)
current_target: NodeIdCurrent target during propagation
phase: EventPhaseCurrent propagation phase
bubbles: boolWhether the event bubbles
cancelable: boolWhether the event is cancelable
default_prevented: boolWhether preventDefault() was called
propagation_stopped: boolWhether stopPropagation() was called
immediate_propagation_stopped: boolWhether stopImmediatePropagation() was called
mouse_x: i32Mouse X position (pixel coordinates)
mouse_y: i32Mouse Y position (pixel coordinates)
Mouse button (0=left, 1=middle, 2=right)
key_code: u32Keyboard scancode
char_code: u32Character value for KeyPress
modifiers: u8Modifier keys bitmask (1=shift, 2=ctrl, 4=alt, 8=meta)
Implementations§
Source§impl Event
impl Event
Sourcepub fn new(event_type: EventType, target: NodeId) -> Self
pub fn new(event_type: EventType, target: NodeId) -> Self
Create a new event with defaults from its type
Sourcepub fn mouse(
event_type: EventType,
target: NodeId,
x: i32,
y: i32,
button: u8,
) -> Self
pub fn mouse( event_type: EventType, target: NodeId, x: i32, y: i32, button: u8, ) -> Self
Create a mouse event
Sourcepub fn keyboard(
event_type: EventType,
target: NodeId,
key_code: u32,
char_code: u32,
) -> Self
pub fn keyboard( event_type: EventType, target: NodeId, key_code: u32, char_code: u32, ) -> Self
Create a keyboard event
Sourcepub fn prevent_default(&mut self)
pub fn prevent_default(&mut self)
Call preventDefault()
Sourcepub fn stop_propagation(&mut self)
pub fn stop_propagation(&mut self)
Call stopPropagation()
Sourcepub fn stop_immediate_propagation(&mut self)
pub fn stop_immediate_propagation(&mut self)
Call stopImmediatePropagation()
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnwindSafe for Event
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)