Enum wry::application::event::Event

source ·
pub enum Event<'a, T>where
    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,
    Opened {
        urls: Vec<Url, Global>,
    },
}
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

Fields

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.
§window_id: WindowId
§event: WindowEvent<'a>

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

§

DeviceEvent

Fields

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.
§device_id: DeviceId

Emitted when the OS sends an event to a device.

§

UserEvent(T)

Emitted when an event is sent from EventLoopProxy::send_event

§

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.

Platform-specific
  • Linux: This is triggered by draw signal of the gtk window. It can be used to detect if the window is requested to redraw. But widgets it contains are usually not tied to its signal. So if you really want to draw each component, please consider using connect_draw method from WidgetExt directly.
§

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.

§

Opened

Fields

§urls: Vec<Url, Global>

Emitted when the app is open by external resources, like opening a file or deeplink.

Implementations§

source§

impl<'a, T> Event<'a, T>

source

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

source

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

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

Trait Implementations§

source§

impl<T> Clone for Event<'static, T>where T: Clone,

source§

fn clone(&self) -> Event<'static, T>

Returns a copy 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<'a, T> Debug for Event<'a, T>where T: Debug + 'static,

source§

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

Formats the value using the given formatter. Read more
source§

impl<'a, T> PartialEq<Event<'a, T>> for Event<'a, T>where T: PartialEq<T> + 'static,

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, T> StructuralPartialEq for Event<'a, T>where T: 'static,

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§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more