[][src]Enum beryllium::Event

pub enum Event {
    Quit {
        timestamp: u32,
    },
    MouseMotion {
        timestamp: u32,
        window_id: u32,
        mouse_id: Option<u32>,
        state: MouseButtonState,
        x: i32,
        y: i32,
        delta_x: i32,
        delta_y: i32,
    },
    MouseButtonEvent {
        timestamp: u32,
        window_id: u32,
        mouse_id: Option<u32>,
        button: MouseButton,
        is_pressed: bool,
        clicks: u8,
        x: i32,
        y: i32,
    },
    MouseWheel {
        timestamp: u32,
        window_id: u32,
        mouse_id: Option<u32>,
        x: i32,
        y: i32,
        is_flipped: bool,
    },
    Keyboard {
        timestamp: u32,
        window_id: u32,
        is_key_down: bool,
        repeat_count: u8,
        key: KeyInfo,
    },
    WindowSizeChanged {
        timestamp: u32,
        window_id: u32,
        width: i32,
        height: i32,
    },
    WindowResized {
        timestamp: u32,
        window_id: u32,
        width: i32,
        height: i32,
    },
    WindowMoved {
        timestamp: u32,
        window_id: u32,
        x: i32,
        y: i32,
    },
    WindowClosed {
        timestamp: u32,
        window_id: u32,
    },
    WindowGainedFocus {
        timestamp: u32,
        window_id: u32,
    },
    WindowLostFocus {
        timestamp: u32,
        window_id: u32,
    },
    MouseEnteredWindow {
        timestamp: u32,
        window_id: u32,
    },
    MouseLeftWindow {
        timestamp: u32,
        window_id: u32,
    },
    WindowHidden {
        timestamp: u32,
        window_id: u32,
    },
    WindowShown {
        timestamp: u32,
        window_id: u32,
    },
    WindowNeedsRepaint {
        timestamp: u32,
        window_id: u32,
    },
    WindowMinimized {
        timestamp: u32,
        window_id: u32,
    },
    WindowMaximized {
        timestamp: u32,
        window_id: u32,
    },
    WindowRestored {
        timestamp: u32,
        window_id: u32,
    },
    UnknownEventType,
}

The various events that can happen.

Variants

Quit

Quit was requested by the user

Fields of Quit

timestamp: u32

Time, in milliseconds, since SDL2 was initialized.

MouseMotion

Event for any time the user moves the mouse within a window, or if warp_mouse_in_window is called.

Fields of MouseMotion

timestamp: u32

Time, in milliseconds, since SDL2 was initialized.

window_id: u32

Window with mouse focus, if any

mouse_id: Option<u32>

The mouse that generated this event. If None it was a touch event.

state: MouseButtonState

State of the mouse buttons during this event

x: i32

X, relative to the window

y: i32

Y, relative to the window

delta_x: i32

Change in X position

delta_y: i32

Change in Y position

MouseButtonEvent

Generated whenever a mouse button is pressed or released.

Fields of MouseButtonEvent

timestamp: u32

Time, in milliseconds, since SDL2 was initialized.

window_id: u32

Window with mouse focus, if any

mouse_id: Option<u32>

The mouse that generated this event. If None it was a touch event.

button: MouseButton

The button that changed

is_pressed: bool

If the button is now pressed or released

clicks: u8

1 for single-click, 2 for double-click, etc

x: i32

X, relative to the window

y: i32

Y, relative to the window

MouseWheel

Generated whenever the user moves the mouse wheel.

Fields of MouseWheel

timestamp: u32

Time, in milliseconds, since SDL2 was initialized.

window_id: u32

Window with mouse focus, if any

mouse_id: Option<u32>

The mouse that generated this event. If None it was a touch event.

x: i32

Horizontal scroll, negative Left or positive Right

y: i32

Vertical scroll, negative to User or positive away from User

is_flipped: bool

Mouse wheel isn't consistent on all platforms. If this bool is set, the meaning of the x and y field is inverted compared to normal.

Keyboard

Keyboard button event information (a press or release).

Fields of Keyboard

timestamp: u32

When the event happened

window_id: u32

The window that was focused when the event happened.

is_key_down: bool

If the key was pressed or released by this event.

repeat_count: u8

If this is a "key repeat" event (usually 0 or 1, though possibly more).

key: KeyInfo

The information about the key being pressed or released.

WindowSizeChanged

Something has changed the size of the window.

If (and only if) this was done by an external action (the user or window manager changing the size of the window, for example), this event will be followed by an Event::WindowResized.

Fields of WindowSizeChanged

timestamp: u32

When the event happened

window_id: u32

The window which experienced a size change.

width: i32

The new width of the window.

height: i32

The new height of the window.

WindowResized

The size of the window has been changed externally.

This event is always preceeded by a Event::WindowSizeChanged, however the inverse is not always true.

The difference between these two events is that Event::WindowResized is only generated if the resize is triggered externally (by a user, their window manager, etc), and not by calls to beryllium functions which may change the size of a window, such as Window::set_size, Window::set_display_mode, whereas Event::WindowSizeChanged is called whenever the size of the window is changed, regardless of the cause.

Fields of WindowResized

timestamp: u32

When the event happened

window_id: u32

The window which experienced a size change.

width: i32

The new width of the window.

height: i32

The new height of the window.

WindowMoved

The window has been moved.

Fields of WindowMoved

timestamp: u32

When the event happened

window_id: u32

The window which experienced a size change.

x: i32

The new x position of the window.

y: i32

The new y position of the window.

WindowClosed

The window manager requests that the window be closed.

Fields of WindowClosed

timestamp: u32

When the event happened

window_id: u32

The window which wants to be closed.

WindowGainedFocus

The window has gained keyboard focus.

Inverse of Event::WindowLostFocus.

Fields of WindowGainedFocus

timestamp: u32

When the event happened

window_id: u32

The window which gained keyboard focus.

WindowLostFocus

The window has lost keyboard focus.

Inverse of Event::WindowGainedFocus.

Fields of WindowLostFocus

timestamp: u32

When the event happened

window_id: u32

The window which lost keyboard focus.

MouseEnteredWindow

The window has gained mouse focus.

Inverse of Event::MouseLeftWindow.

Fields of MouseEnteredWindow

timestamp: u32

When the event happened

window_id: u32

The window which gained mouse focus.

MouseLeftWindow

The window has lost mouse focus.

Inverse of Event::MouseEnteredWindow.

Fields of MouseLeftWindow

timestamp: u32

When the event happened

window_id: u32

The window which lost mouse focus.

WindowHidden

The window has been hidden.

Inverse of Event::WindowShown.

Fields of WindowHidden

timestamp: u32

When the event happened

window_id: u32

The window which gained or lost mouse focus.

WindowShown

The window has been shown.

Inverse of Event::WindowHidden.

Fields of WindowShown

timestamp: u32

When the event happened

window_id: u32

The window which gained or lost mouse focus.

WindowNeedsRepaint

The window needs repainting for one reason or another.

This maps to SDL_WINDOWEVENT_EXPOSED, but has been renamed in order to make it more clear what the event indicates.

Fields of WindowNeedsRepaint

timestamp: u32

When the event happened

window_id: u32

The window which gained or lost mouse focus.

WindowMinimized

The window has been minimized.

Fields of WindowMinimized

timestamp: u32

When the event happened

window_id: u32

The window which has been minimized.

WindowMaximized

The window has been maximized.

Fields of WindowMaximized

timestamp: u32

When the event happened

window_id: u32

The window which has been maximized.

WindowRestored

The window has been restored to normal size and position.

Fields of WindowRestored

timestamp: u32

When the event happened

window_id: u32

The window which has been restored.

UnknownEventType

It's always possible that we'll load some future version which will have event variants we don't understand, which we have to just ignore.

Trait Implementations

impl Clone for Event[src]

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

Performs copy-assignment from source. Read more

impl Copy for Event[src]

impl From<SDL_Event> for Event[src]

fn from(event: SDL_Event) -> Self[src]

Parses "without fail", but will turn unknown events into UnknownEventType.

So, it's not lossless I guess. Whatever.

impl Debug for Event[src]

Auto Trait Implementations

impl Send for Event

impl Sync for Event

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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

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

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.

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.

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

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

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