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
pub fn hits_pointer(
&mut self,
cx: &mut Cx,
component_id: ComponentId,
rect: Option<Rect>
) -> Event
pub fn hits_pointer(
&mut self,
cx: &mut Cx,
component_id: ComponentId,
rect: Option<Rect>
) -> Event
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
Auto Trait Implementations
impl RefUnwindSafe for Event
impl UnwindSafe for Event
Blanket Implementations
Mutably borrows from an owned value. Read more