Enum slint::platform::WindowEvent
#[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§
§impl WindowEvent
impl WindowEvent
pub fn position(&self) -> Option<LogicalPosition>
pub fn position(&self) -> Option<LogicalPosition>
The position of the cursor for this event, if any
Trait Implementations§
§impl Clone for WindowEvent
impl Clone for WindowEvent
§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§impl Debug for WindowEvent
impl Debug for WindowEvent
§impl PartialEq for WindowEvent
impl PartialEq for WindowEvent
§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 Freeze for WindowEvent
impl RefUnwindSafe for WindowEvent
impl Send for WindowEvent
impl !Sync for WindowEvent
impl Unpin for WindowEvent
impl UnwindSafe for WindowEvent
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§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>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§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.§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.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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