Trait piston_window::GenericEvent[][src]

pub trait GenericEvent: AfterRenderEvent + CloseEvent + ControllerAxisEvent + CursorEvent + FocusEvent + IdleEvent + MouseCursorEvent + MouseRelativeEvent + MouseScrollEvent + ButtonEvent + PressEvent + ReleaseEvent + RenderEvent + ResizeEvent + TextEvent + TouchEvent + UpdateEvent + From<Input> + From<Loop> + Into<Option<Input>> + Into<Option<Loop>> {
    pub fn event_id(&self) -> EventId;
pub fn with_args<F, U>(&'a self, f: F) -> U
        F: FnMut(&(dyn Any + 'static)) -> U
pub fn time_stamp(&self) -> Option<u32>; }

Implemented by all events.

Use this trait when you need to handle events, e.g. fn event(&mut self, e: &impl GenericEvent). Events are usually handles by controllers (in the Model-View-Controller programming pattern). There is no requirement that you need to implement some trait for controllers, just that the standard convention for handling events is through a event method. For more information about Model-View-Controller, see Wikipedia article.

This trait makes it possible to auto impl new events for all types that implements GenericEvent. This way, you can define your own event types without breaking compatibility with Piston.

Required methods

pub fn event_id(&self) -> EventId[src]

The id of this event.

pub fn with_args<F, U>(&'a self, f: F) -> U where
    F: FnMut(&(dyn Any + 'static)) -> U, 

Calls closure with arguments

pub fn time_stamp(&self) -> Option<u32>[src]

Gets the time stamp of this event.

Measured in milliseconds since initialization of window.

Loading content...


impl GenericEvent for Event[src]

Loading content...