Enum winit::event::Event[][src]

pub enum Event<'a, T: 'static> {
    NewEvents(StartCause),
    WindowEvent {
        window_id: WindowId,
        event: WindowEvent<'a>,
    },
    DeviceEvent {
        device_id: DeviceId,
        event: DeviceEvent,
    },
    UserEvent(T),
    Suspended,
    Resumed,
    MainEventsCleared,
    RedrawRequested(WindowId),
    RedrawEventsCleared,
    LoopDestroyed,
}
Expand description

Describes a generic event.

See the module-level docs for more information on the event loop manages each event.

Variants

NewEvents(StartCause)
Expand description

Emitted when new events arrive from the OS to be processed.

This event type is useful as a place to put code that should be done before you start processing events, such as updating frame timing information for benchmarking or checking the StartCause to see if a timer set by ControlFlow::WaitUntil has elapsed.

WindowEvent
Expand description

Emitted when the OS sends an event to a winit window.

Show fields

Fields of WindowEvent

window_id: WindowIdevent: WindowEvent<'a>
DeviceEvent
Expand description

Emitted when the OS sends an event to a device.

Show fields

Fields of DeviceEvent

device_id: DeviceIdevent: DeviceEvent
UserEvent(T)
Expand description

Emitted when an event is sent from EventLoopProxy::send_event

Suspended
Expand description

Emitted when the application has been suspended.

Resumed
Expand description

Emitted when the application has been resumed.

MainEventsCleared
Expand description

Emitted when all of the event loop’s input events have been processed and redraw processing is about to begin.

This event is useful as a place to put your code that should be run after all state-changing events have been handled and you want to do stuff (updating state, performing calculations, etc) that happens as the “main body” of your event loop. If your program only draws graphics when something changes, it’s usually better to do it in response to Event::RedrawRequested, which gets emitted immediately after this event. Programs that draw graphics continuously, like most games, can render here unconditionally for simplicity.

RedrawRequested(WindowId)
Expand description

Emitted after MainEventsCleared when a window should be redrawn.

This gets triggered in two scenarios:

  • The OS has performed an operation that’s invalidated the window’s contents (such as resizing the window).
  • The application has explicitly requested a redraw via Window::request_redraw.

During each iteration of the event loop, Winit will aggregate duplicate redraw requests into a single event, to help avoid duplicating rendering work.

Mainly of interest to applications with mostly-static graphics that avoid redrawing unless something changes, like most non-game GUIs.

RedrawEventsCleared
Expand description

Emitted after all RedrawRequested events have been processed and control flow is about to be taken away from the program. If there are no RedrawRequested events, it is emitted immediately after MainEventsCleared.

This event is useful for doing any cleanup or bookkeeping work after all the rendering tasks have been completed.

LoopDestroyed
Expand description

Emitted when the event loop is being shut down.

This is irreversable - if this event is emitted, it is guaranteed to be the last event that gets emitted. You generally want to treat this as an “do on quit” event.

Implementations

impl<'a, T> Event<'a, T>[src]

pub fn map_nonuser_event<U>(self) -> Result<Event<'a, U>, Event<'a, T>>[src]

pub fn to_static(self) -> Option<Event<'static, T>>[src]

If the event doesn’t contain a reference, turn it into an event with a 'static lifetime. Otherwise, return None.

Trait Implementations

impl<T: Clone> Clone for Event<'static, T>[src]

fn clone(&self) -> Self[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<'a, T: Debug + 'static> Debug for Event<'a, T>[src]

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

Formats the value using the given formatter. Read more

impl<'a, T: PartialEq + 'static> PartialEq<Event<'a, T>> for Event<'a, T>[src]

fn eq(&self, other: &Event<'a, T>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Event<'a, T>) -> bool[src]

This method tests for !=.

impl<'a, T: 'static> StructuralPartialEq for Event<'a, T>[src]

Auto Trait Implementations

impl<'a, T> RefUnwindSafe for Event<'a, T> where
    T: RefUnwindSafe

impl<'a, T> Send for Event<'a, T> where
    T: Send

impl<'a, T> Sync for Event<'a, T> where
    T: Sync

impl<'a, T> Unpin for Event<'a, T> where
    T: Unpin

impl<'a, T> !UnwindSafe for Event<'a, T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.