Enum nannou::event::WindowEvent
source · pub enum WindowEvent {
Show 19 variants
Moved(Point2),
KeyPressed(Key),
KeyReleased(Key),
ReceivedCharacter(char),
MouseMoved(Point2),
MousePressed(MouseButton),
MouseReleased(MouseButton),
MouseEntered,
MouseExited,
MouseWheel(MouseScrollDelta, TouchPhase),
Resized(Vec2),
HoveredFile(PathBuf),
DroppedFile(PathBuf),
HoveredFileCancelled,
Touch(TouchEvent),
TouchPressure(TouchpadPressure),
Focused,
Unfocused,
Closed,
}
Expand description
A simplified version of winit’s WindowEvent
type to make it easier to get started.
All co-ordinates and dimensions are DPI-agnostic scalar values.
Co-ordinates for each window are as follows:
(0.0, 0.0)
is the centre of the window.- positive
x
points to the right, negativex
points to the left. - positive
y
points upwards, negativey
points downwards. - positive
z
points into the screen, negativez
points out of the screen.
Variants§
Moved(Point2)
The window has been moved to a new position.
KeyPressed(Key)
The given keyboard key was pressed.
KeyReleased(Key)
The given keyboard key was released.
ReceivedCharacter(char)
Character input received event.
MouseMoved(Point2)
The mouse moved to the given x, y position.
MousePressed(MouseButton)
The given mouse button was pressed.
MouseReleased(MouseButton)
The given mouse button was released.
MouseEntered
The mouse entered the window.
MouseExited
The mouse exited the window.
MouseWheel(MouseScrollDelta, TouchPhase)
A mouse wheel movement or touchpad scroll occurred.
Resized(Vec2)
The window was resized to the given dimensions (in DPI-agnostic points, not pixels).
HoveredFile(PathBuf)
A file at the given path was hovered over the window.
DroppedFile(PathBuf)
A file at the given path was dropped onto the window.
HoveredFileCancelled
A file at the given path that was hovered over the window was cancelled.
Touch(TouchEvent)
Received a touch event.
TouchPressure(TouchpadPressure)
Touchpad pressure event.
At the moment, only supported on Apple forcetouch-capable macbooks. The parameters are: pressure level (value between 0 and 1 representing how hard the touchpad is being pressed) and stage (integer representing the click level).
Focused
The window gained focus.
Unfocused
The window lost focus.
Closed
The window was closed and is no longer stored in the App
.
Implementations§
source§impl WindowEvent
impl WindowEvent
sourcepub fn from_winit_window_event(
event: &WindowEvent<'_>,
win_w: f64,
win_h: f64,
scale_factor: f64
) -> Option<Self>
pub fn from_winit_window_event( event: &WindowEvent<'_>, win_w: f64, win_h: f64, scale_factor: f64 ) -> Option<Self>
Produce a simplified, new-user-friendly version of the given winit::event::WindowEvent
.
This strips rarely needed technical information from the event type such as information about the source device, scancodes for keyboard events, etc to make the experience of pattern matching on window events nicer for new users.
This also interprets the raw pixel positions and dimensions of the raw event into a
dpi-agnostic scalar value where (0, 0, 0) is the centre of the screen with the y
axis
increasing in the upwards direction.
If the user requires this extra information, they should use the raw
field of the
WindowEvent
type rather than the simple
one.
Trait Implementations§
source§impl Clone for WindowEvent
impl Clone for WindowEvent
source§fn clone(&self) -> WindowEvent
fn clone(&self) -> WindowEvent
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for WindowEvent
impl Debug for WindowEvent
source§impl PartialEq for WindowEvent
impl PartialEq for WindowEvent
source§fn eq(&self, other: &WindowEvent) -> bool
fn eq(&self, other: &WindowEvent) -> bool
self
and other
values to be equal, and is used
by ==
.impl StructuralPartialEq for WindowEvent
Auto Trait Implementations§
impl RefUnwindSafe for WindowEvent
impl Send for WindowEvent
impl Sync for WindowEvent
impl Unpin for WindowEvent
impl UnwindSafe for WindowEvent
Blanket Implementations§
source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
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, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
source§fn convert_into(self) -> U
fn convert_into(self) -> U
source§fn convert_unclamped_into(self) -> U
fn convert_unclamped_into(self) -> U
source§fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
OutOfBounds
error is returned which contains the unclamped color. Read more