#[non_exhaustive]#[repr(u32)]pub enum WindowEvent {
PointerPressed {
position: LogicalPosition,
button: PointerEventButton,
},
PointerReleased {
position: LogicalPosition,
button: PointerEventButton,
},
PointerMoved {
position: LogicalPosition,
},
PointerScrolled {
position: LogicalPosition,
delta_x: f32,
delta_y: f32,
},
PointerExited,
KeyPressed {
text: SharedString,
},
KeyPressRepeated {
text: SharedString,
},
KeyReleased {
text: SharedString,
},
ScaleFactorChanged {
scale_factor: f32,
},
Resized {
size: LogicalSize,
},
CloseRequested,
WindowActiveChanged(bool),
}
Expand description
A event that describes user input or windowing system events.
Slint backends typically receive events from the windowing system, translate them to this
enum and deliver them to the scene of items via slint::Window::dispatch_event()
.
The pointer variants describe events originating from an input device such as a mouse or a contact point on a touch-enabled surface.
All position fields are in logical window coordinates.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
PointerPressed
A pointer was pressed.
PointerReleased
A pointer was released.
PointerMoved
The position of the pointer has changed.
Fields
position: LogicalPosition
PointerScrolled
The wheel button of a mouse was rotated to initiate scrolling.
Fields
position: LogicalPosition
PointerExited
The pointer exited the window.
KeyPressed
A key was pressed.
Fields
text: SharedString
KeyPressRepeated
A key press was auto-repeated.
Fields
text: SharedString
KeyReleased
A key was released.
Fields
text: SharedString
ScaleFactorChanged
The window’s scale factor has changed. This can happen for example when the display’s resolution changes, the user selects a new scale factor in the system settings, or the window is moved to a different screen. Platform implementations should dispatch this event also right after the initial window creation, to set the initial scale factor the windowing system provided for the window.
Fields
Resized
The window was resized.
The backend must send this event to ensure that the width
and height
property of the root Window
element are properly set.
Fields
size: LogicalSize
The new logical size of the window
CloseRequested
The user requested to close the window.
The backend should send this event when the user tries to close the window,for example by pressing the close button.
This will have the effect of invoking the callback set in Window::on_close_requested()
and then hiding the window depending on the return value of the callback.
WindowActiveChanged(bool)
The Window was activated or de-activated.
The backend should dispatch this event with true when the window gains focus and false when the window loses focus.
Implementations§
Source§impl WindowEvent
impl WindowEvent
Sourcepub fn position(&self) -> Option<LogicalPosition>
pub fn position(&self) -> Option<LogicalPosition>
The position of the cursor for this event, if any
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 more