Skip to main content

Event

Enum Event 

Source
pub enum Event {
Show 33 variants PointerEntered { id: WidgetId, }, PointerExited { id: WidgetId, }, PointerMoved { id: WidgetId, position: Point, }, PointerPressed { id: WidgetId, button: MouseButton, position: Point, count: u8, }, PointerReleased { id: WidgetId, button: MouseButton, position: Point, count: u8, }, Clicked { id: WidgetId, button: MouseButton, count: u8, }, Scrolled { id: WidgetId, delta: Point, }, KeyPressed { id: WidgetId, key: Key, modifiers: Modifiers, repeat: bool, }, KeyReleased { id: WidgetId, key: Key, modifiers: Modifiers, }, TextEntered { id: WidgetId, text: String, }, FocusGained { id: WidgetId, }, FocusLost { id: WidgetId, }, Activated { id: WidgetId, }, Toggled { id: WidgetId, checked: bool, }, ValueChanged { id: WidgetId, }, SelectionChanged { id: WidgetId, }, TextChanged { id: WidgetId, }, EditingFinished { id: WidgetId, }, Triggered { id: WidgetId, action: String, }, ContextMenuRequested { id: WidgetId, position: Point, }, PropertyChanged { id: WidgetId, name: String, }, ViewportChanged { id: WidgetId, offset: Point, }, Shown { id: WidgetId, }, Hidden { id: WidgetId, }, Resized { id: WidgetId, size: Size, }, Moved { id: WidgetId, origin: Point, }, Removed { id: WidgetId, }, WindowResized { size: Size, }, WindowFocusChanged { focused: bool, }, CloseRequested, Tick { elapsed: Duration, }, Engine(EngineEvent), Custom(CustomEvent),
}
Expand description

An event generated by Pushrod or by a Widget.

Widgets receive these in Widget::handle_event, and applications receive the ones Widgets emit through callbacks or Engine::next_event. Positions are in window coordinates.

Variants§

§

PointerEntered

The pointer moved onto widget id.

Fields

§id: WidgetId

The widget the pointer entered.

§

PointerExited

The pointer moved off widget id.

Fields

§id: WidgetId

The widget the pointer left.

§

PointerMoved

The pointer moved. Sent to the capturing widget, or the one under the pointer.

Fields

§id: WidgetId

The widget receiving the motion.

§position: Point

The pointer position.

§

PointerPressed

A mouse button went down over widget id.

Fields

§id: WidgetId

The widget under the pointer.

§button: MouseButton

The button that went down.

§position: Point

The pointer position.

§count: u8

The click count (1 single, 2 double).

§

PointerReleased

A mouse button went up. Sent to the widget that captured the press.

Fields

§id: WidgetId

The widget receiving the release.

§button: MouseButton

The button that went up.

§position: Point

The pointer position.

§count: u8

The click count (1 single, 2 double).

§

Clicked

Widget id was clicked.

Fields

§id: WidgetId

The widget that was clicked.

§button: MouseButton

The button used.

§count: u8

The click count (1 single, 2 double).

§

Scrolled

The wheel or trackpad scrolled over widget id.

Fields

§id: WidgetId

The widget under the pointer.

§delta: Point

How far it scrolled, horizontally (x) and vertically (y).

§

KeyPressed

A key went down (or repeated) while widget id had the keyboard.

Fields

§id: WidgetId

The widget with the keyboard.

§key: Key

The key.

§modifiers: Modifiers

The modifier keys held.

§repeat: bool

true if this is an auto-repeat.

§

KeyReleased

A key went up while widget id had the keyboard.

Fields

§id: WidgetId

The widget with the keyboard.

§key: Key

The key.

§modifiers: Modifiers

The modifier keys held.

§

TextEntered

Text was typed into widget id.

Fields

§id: WidgetId

The widget with the keyboard.

§text: String

The text typed.

§

FocusGained

Widget id became the keyboard focus.

Fields

§id: WidgetId

The widget that gained focus.

§

FocusLost

Widget id stopped being the keyboard focus.

Fields

§id: WidgetId

The widget that lost focus.

§

Activated

Widget id was activated.

Fields

§id: WidgetId

The widget activated.

§

Toggled

Widget id was toggled.

Fields

§id: WidgetId

The widget toggled.

§checked: bool

The new state.

§

ValueChanged

The value of widget id changed.

Fields

§id: WidgetId

The widget whose value changed.

§

SelectionChanged

The selection of widget id changed.

Fields

§id: WidgetId

The widget whose selection changed.

§

TextChanged

The text of widget id changed.

Fields

§id: WidgetId

The widget whose text changed.

§

EditingFinished

Editing in widget id finished.

Fields

§id: WidgetId

The widget that was edited.

§

Triggered

A named action was triggered by widget id.

Fields

§id: WidgetId

The widget that triggered it.

§action: String

The action name.

§

ContextMenuRequested

A context menu was requested at position over widget id.

Fields

§id: WidgetId

The widget under the pointer.

§position: Point

Where the menu was requested.

§

PropertyChanged

A property of widget id changed.

Fields

§id: WidgetId

The widget whose property changed.

§name: String

The property name.

§

ViewportChanged

The visible area of scrolling widget id moved.

Fields

§id: WidgetId

The scrolling widget.

§offset: Point

The new scroll offset.

§

Shown

Widget id became visible.

Fields

§id: WidgetId

The widget shown.

§

Hidden

Widget id became hidden.

Fields

§id: WidgetId

The widget hidden.

§

Resized

Widget id changed size.

Fields

§id: WidgetId

The widget resized.

§size: Size

Its new size.

§

Moved

Widget id changed origin.

Fields

§id: WidgetId

The widget moved.

§origin: Point

Its new origin.

§

Removed

Widget id was removed from the tree.

Fields

§id: WidgetId

The widget removed.

§

WindowResized

The window changed size.

Fields

§size: Size

The new window size.

§

WindowFocusChanged

The window gained or lost focus.

Fields

§focused: bool

true if the window now has focus.

§

CloseRequested

The user asked to close the window.

§

Tick

A frame passed while a widget animates.

Fields

§elapsed: Duration

The time since the previous tick.

§

Engine(EngineEvent)

An action Pushrod performed internally.

§

Custom(CustomEvent)

An application- or library-defined event.

Implementations§

Source§

impl Event

Source

pub fn payload<T: Any>(&self) -> Option<&T>

Reads the payload of a custom event as a T.

§Returns

The payload, or None if this is not Event::Custom or the payload is not a T.

Source

pub fn widget_id(&self) -> Option<WidgetId>

The widget a widget-addressed event is for.

§Returns

The WidgetId, or None for window-level, engine, custom and raw events.

Source

pub fn kind(&self) -> EventKind

Returns the kind of this event, without its data.

§Returns

The matching EventKind.

Source

pub fn widget(&self) -> Option<WidgetId>

Returns the widget this event concerns, if any.

Window, time, engine, custom, and raw events concern no single widget.

§Returns

The WidgetId, or None.

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Event

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Event

§

impl !Send for Event

§

impl !Sync for Event

§

impl !UnwindSafe for Event

§

impl Freeze for Event

§

impl Unpin for Event

§

impl UnsafeUnpin for Event

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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> ToOwned for T
where T: Clone,

Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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.