Skip to main content

WindowEvent

Enum WindowEvent 

Source
pub enum WindowEvent {
    Resized(PhysicalSize<u32>),
    Moved(PhysicalPosition<i32>),
    CloseRequested {
        signal_tx: Sender<bool>,
    },
    Destroyed,
    Focused(bool),
    ScaleFactorChanged {
        scale_factor: f64,
        new_inner_size: PhysicalSize<u32>,
    },
    DragDrop(DragDropEvent),
    ThemeChanged(Theme),
    Suspended,
    Resumed,
}
Expand description

An event from a window.

Variants§

§

Resized(PhysicalSize<u32>)

The size of the window has changed. Contains the client area’s new dimensions.

§

Moved(PhysicalPosition<i32>)

The position of the window has changed. Contains the window’s new position.

§

CloseRequested

The window has been requested to close.

Fields

§signal_tx: Sender<bool>

A signal sender. If a true value is emitted, the window won’t be closed.

§

Destroyed

The window has been destroyed.

§

Focused(bool)

The window gained or lost focus.

The parameter is true if the window has gained focus, and false if it has lost focus.

§

ScaleFactorChanged

The window’s scale factor has changed.

The following user actions can cause DPI changes:

  • Changing the display’s resolution.
  • Changing the display’s scale factor (e.g. in Control Panel on Windows).
  • Moving the window to a display with a different scale factor.

Fields

§scale_factor: f64

The new scale factor.

§new_inner_size: PhysicalSize<u32>

The window inner size.

§

DragDrop(DragDropEvent)

An event associated with the drag and drop action.

§

ThemeChanged(Theme)

The system window theme has changed.

Applications might wish to react to this to change the theme of the content of the window when the system changes the window theme.

§

Suspended

Available on mobile only.

Emitted when the application has been suspended.

§Platform-specific
  • Android: This is triggered by onPause method of the Activity.
  • iOS: This is triggered by applicationWillResignActive method of the UIApplicationDelegate.
  • Linux / macOS / Windows: Unsupported.
§

Resumed

Available on mobile only.

Emitted when the application has been resumed.

§Platform-specific
  • Android: This is triggered by onResume method of the Activity. The first onResume() is ignored to match the iOS implementation, since that is called on activity creation.
  • iOS: This is triggered by applicationWillEnterForeground method of the UIApplicationDelegate.
  • Linux / macOS / Windows: Unsupported.

Trait Implementations§

Source§

impl Clone for WindowEvent

Source§

fn clone(&self) -> WindowEvent

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WindowEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> UserEvent for T
where T: Debug + Clone + Send + 'static,