Enum tao::event::Event[][src]

#[non_exhaustive]
pub enum Event<'a, T: 'static> {
Show variants NewEvents(StartCause), WindowEvent { window_id: WindowId, event: WindowEvent<'a>, }, DeviceEvent { device_id: DeviceId, event: DeviceEvent, }, UserEvent(T), MenuEvent { window_id: Option<WindowId>, menu_id: MenuId, origin: MenuType, }, TrayEvent { bounds: Rectangle, event: TrayEvent, position: PhysicalPosition<f64>, }, GlobalShortcutEvent(AcceleratorId), 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 (Non-exhaustive)

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
NewEvents(StartCause)

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

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

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
Show fields

Fields of WindowEvent

window_id: WindowIdevent: WindowEvent<'a>
DeviceEvent

Emitted when the OS sends an event to a device.

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
Show fields

Fields of DeviceEvent

device_id: DeviceIdevent: DeviceEvent
UserEvent(T)

Emitted when an event is sent from EventLoopProxy::send_event

MenuEvent

Emitted when a menu has been clicked. There are two types of menu event. One comes from the menu bar, the other comes from the status bar.

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
Show fields

Fields of MenuEvent

window_id: Option<WindowId>menu_id: MenuIdorigin: MenuType
TrayEvent

Emitted when tray has been clicked.

Platform-specific

  • iOS / Android / Linux: Unsupported.
This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
Show fields

Fields of TrayEvent

bounds: Rectangleevent: TrayEventposition: PhysicalPosition<f64>
GlobalShortcutEvent(AcceleratorId)

Emitted when a global shortcut is triggered.

Platform-specific

  • iOS / Android: Unsupported.
Suspended

Emitted when the application has been suspended.

Resumed

Emitted when the application has been resumed.

MainEventsCleared

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)

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, Tao 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

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

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

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

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

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

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.