pub enum Event {
Show 30 variants None, Construct, AppFocus, AppFocusLost, NextFrame, WindowDragQuery(WindowDragQueryEvent), WindowCloseRequested(WindowCloseRequestedEvent), WindowClosed(WindowClosedEvent), WindowGeomChange(WindowGeomChangeEvent), WindowResizeLoop(WindowResizeLoopEvent), PointerDown(PointerDownEvent), PointerMove(PointerMoveEvent), PointerHover(PointerHoverEvent), PointerUp(PointerUpEvent), PointerScroll(PointerScrollEvent), Timer(TimerEvent), Signal(SignalEvent), Command(CommandId), KeyFocus(KeyFocusEvent), KeyFocusLost(KeyFocusEvent), KeyDown(KeyEvent), KeyUp(KeyEvent), TextInput(TextInputEvent), TextCopy, WebSocketMessage(WebSocketMessageEvent), AppOpenFiles(AppOpenFilesEvent), FileDragBegin, FileDragUpdate(FileDragUpdateEvent), FileDragCancel, System(SystemEvent),
}
Expand description

Global event passed into an application’s handle function. See contained structs for more details.

Variants

None

No event, to avoid unwrapping Option<Event> all over the place.

Construct

App starts up; should be the very first event that gets fired.

AppFocus

App gained focus.

TODO(JP): Rename to AppFocusGained to be more symmetric with Event::AppFocusLost?

AppFocusLost

App lost focus.

NextFrame

New frame requested. Useful for animations; you can request this using Cx::request_next_frame.

WindowDragQuery(WindowDragQueryEvent)

The operating system inquired if a Window can be dragged.

WindowCloseRequested(WindowCloseRequestedEvent)

The user requested to close the Window.

WindowClosed(WindowClosedEvent)

The Window actually closed.

WindowGeomChange(WindowGeomChangeEvent)

Geometry of a Window changed (position, size, etc).

WindowResizeLoop(WindowResizeLoopEvent)

The user started or ended resizing the Window.

TODO(JP): Mostly for internal use in Windows; we might not want to expose this to end users?

PointerDown(PointerDownEvent)

A pointer (mouse, touch, etc) was pressed down.

Someone has to call Cx::set_key_focus or Cx::keep_key_focus when handling, otherwise the key focus will be reset.

PointerMove(PointerMoveEvent)

A pointer (mouse, touch, etc) was moved.

PointerHover(PointerHoverEvent)

The mouse was hovered over the screen. This cannot fire from touch input.

PointerUp(PointerUpEvent)

A pointer (mouse, touch, etc) was released.

PointerScroll(PointerScrollEvent)

A pointer (mouse, touch, etc) triggered a scroll.

Timer(TimerEvent)

A Timer was requested using Cx::start_timer.

Signal(SignalEvent)

A signal was fired using Cx::send_signal.

Command(CommandId)

KeyFocus(KeyFocusEvent)

Keyboard focus changed between components.

KeyFocusLost(KeyFocusEvent)

Keyboard focus was lost by a component. Returned from Event::hits_keyboard.

KeyDown(KeyEvent)

A key was pressed down. Rely on Event::TextInput for text input instead of this.

KeyUp(KeyEvent)

A key was released. Rely on Event::TextInput for text input instead of this.

TextInput(TextInputEvent)

Some text was inputted. Rely on this for text input instead of KeyEvent.

TextCopy

Text was requested to be copied to the clipboard.

WebSocketMessage(WebSocketMessageEvent)

A websocket message was received.

AppOpenFiles(AppOpenFilesEvent)

Intended for platforms that can register a file type to an application. Fires:

  • when application starts with a file
  • when Window::create_add_drop_target_for_app_open_files is set and a file is dragged and released onto the window
  • when the application is already started and an associated file is double-clicked

FileDragBegin

When Window::create_add_drop_target_for_app_open_files is set and a file is dragged (without being released) onto the window

FileDragUpdate(FileDragUpdateEvent)

When a file is being dragged and the mouse position changes

FileDragCancel

When a file is being dragged and the mouse moves out of the window

System(SystemEvent)

Events that are handled internally and are not propagated to an application handle method.

Implementations

Checks if an Event is a pointer-event with coordinates falling inside Rect, or already has an associated ComponentId that matches the given one.

For unhandled Event::PointerDown and Event::PointerHover events, the given ComponentId will be associated with that pointer (if the event falls in Rect).

For Event::PointerUp (and Event::PointerHover with HoverState::Out) it’s the other way around: if the pointer is associated with the given ComponentId, it will be returned regardless of Rect.

We pass in Option<Rect> instead of Rect for convenience, since it often comes from Area::get_rect_for_first_instance, which returns Option<Rect>. When passing in None, we always return Event::None.

Process a keyboard/text-related event, if the given ComponentId has key focus (Cx::key_focus).

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

Returns the “default value” for a type. Read more

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)

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.