pub enum Event {
MouseMove {
pos: Point,
},
MouseDown {
pos: Point,
button: MouseButton,
modifiers: Modifiers,
},
MouseUp {
pos: Point,
button: MouseButton,
modifiers: Modifiers,
},
KeyDown {
key: Key,
modifiers: Modifiers,
},
KeyUp {
key: Key,
modifiers: Modifiers,
},
FocusGained,
FocusLost,
MouseWheel {
pos: Point,
delta_y: f64,
delta_x: f64,
modifiers: Modifiers,
},
FileDropped {
pos: Point,
paths: Vec<PathBuf>,
},
}Expand description
A GUI event delivered to a widget.
Coordinate positions are in the local coordinate space of the widget receiving the event (bottom-left origin, Y-up). The framework translates positions as it descends the widget tree.
Variants§
MouseMove
The cursor moved to pos (may be outside widget bounds — used to
clear hover state).
MouseDown
A mouse button was pressed at pos.
MouseUp
A mouse button was released at pos.
KeyDown
A key was pressed while this widget (or a descendant) had focus.
KeyUp
A key was released.
FocusGained
Sent by the framework when this widget gains keyboard focus.
FocusLost
Sent by the framework when this widget loses keyboard focus.
MouseWheel
Mouse wheel scrolled. Convention matches winit /
WheelEvent after the OS applies its natural-scroll
preference: positive delta_y means the user wants to see
content ABOVE the current view (wheel rotated forward on
Windows / wheel forward + natural-scroll on macOS). Scroll
containers should DECREASE their scroll offset when delta_y
is positive. delta_x follows the same sign rule for
horizontal scroll (positive = see content to the LEFT).
Magnitude is in logical pixels; line deltas should be
pre-scaled by the platform shell (~40 px per line).
FileDropped
One or more files were dropped onto the window at pos.
paths is non-empty. Native windowing layers (winit) typically
emit one path per WindowEvent::DroppedFile — the framework
either forwards each as its own FileDropped event, or batches
drops within a single gesture into one event. Receivers should
not rely on batching behaviour: handle each path in the vec.
Coordinates follow the same convention as MouseMove/MouseDown:
widget-local Y-up. The cursor lives at pos at the moment of
drop, so widgets can spawn objects under the user’s intent.
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 UnsafeUnpin for Event
impl UnwindSafe for Event
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>, which can then be
downcast into Box<dyn 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>, which 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.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
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