pub enum Event {
Show 17 variants
Copy,
Cut,
Paste(String),
Text(String),
Key {
key: Key,
physical_key: Option<Key>,
pressed: bool,
repeat: bool,
modifiers: Modifiers,
},
PointerMoved(Pos2),
PointerButton {
pos: Pos2,
button: PointerButton,
pressed: bool,
modifiers: Modifiers,
},
PointerGone,
Scroll(Vec2),
Zoom(f32),
CompositionStart,
CompositionUpdate(String),
CompositionEnd(String),
Touch {
device_id: TouchDeviceId,
id: TouchId,
phase: TouchPhase,
pos: Pos2,
force: Option<f32>,
},
MouseWheel {
unit: MouseWheelUnit,
delta: Vec2,
modifiers: Modifiers,
},
WindowFocused(bool),
Screenshot {
viewport_id: ViewportId,
image: Arc<ColorImage>,
},
}
Expand description
An input event generated by the integration.
This only covers events that egui cares about.
Variants§
Copy
The integration detected a “copy” event (e.g. Cmd+C).
Cut
The integration detected a “cut” event (e.g. Cmd+X).
Paste(String)
The integration detected a “paste” event (e.g. Cmd+V).
Text(String)
Text input, e.g. via keyboard.
When the user presses enter/return, do not send a Text
(just Key::Enter
).
Key
Fields
key: Key
The logical key, heeding the users keymap.
For instance, if the user is using Dvorak keyboard layout, this will take that into account.
physical_key: Option<Key>
The physical key, corresponding to the actual position on the keyboard.
This ignores keymaps, so it is not recommended to use this. The only thing it makes sense for is things like games, where e.g. the physical location of WSAD on QWERTY should always map to movement, even if the user is using Dvorak or AZERTY.
eframe
does not (yet) implement this on web.
repeat: bool
If this is a pressed
event, is it a key-repeat?
On many platforms, holding down a key produces many repeated “pressed” events for it, so called key-repeats. Sometimes you will want to ignore such events, and this lets you do that.
egui will automatically detect such repeat events and mark them as such here.
Therefore, if you are writing an egui integration, you do not need to set this (just set it to false
).
A key was pressed or released.
PointerMoved(Pos2)
The mouse or touch moved to a new place.
PointerButton
Fields
What mouse button? For touches, use PointerButton::Primary
.
A mouse button was pressed or released (or a touch started or stopped).
PointerGone
The mouse left the screen, or the last/primary touch input disappeared.
This means there is no longer a cursor on the screen for hovering etc.
On touch-up first send PointerButton{pressed: false, …}
followed by PointerLeft
.
Scroll(Vec2)
How many points (logical pixels) the user scrolled.
The direction of the vector indicates how to move the content that is being viewed. So if you get positive values, the content being viewed should move to the right and down, revealing new things to the left and up.
A positive X-value indicates the content is being moved right, as when swiping right on a touch-screen or track-pad with natural scrolling.
A positive Y-value indicates the content is being moved down, as when swiping down on a touch-screen or track-pad with natural scrolling.
Shift-scroll should result in horizontal scrolling (it is up to the integrations to do this).
Zoom(f32)
Zoom scale factor this frame (e.g. from ctrl-scroll or pinch gesture).
zoom = 1
: no change.zoom < 1
: pinch togetherzoom > 1
: pinch spread
CompositionStart
IME composition start.
CompositionUpdate(String)
A new IME candidate is being suggested.
CompositionEnd(String)
IME composition ended with this final result.
Touch
Fields
device_id: TouchDeviceId
Hashed device identifier (if available; may be zero). Can be used to separate touches from different devices.
phase: TouchPhase
One of: start move end cancel.
On touch screens, report this in addition to
Self::PointerMoved
, Self::PointerButton
, Self::PointerGone
MouseWheel
Fields
unit: MouseWheelUnit
The unit of scrolling: points, lines, or pages.
A raw mouse wheel event as sent by the backend (minus the z coordinate),
for implementing alternative custom controls.
Note that the same event can also trigger Self::Zoom
and Self::Scroll
,
so you probably want to handle only one of them.
WindowFocused(bool)
The native window gained or lost focused (e.g. the user clicked alt-tab).
Screenshot
The reply of a screenshot requested with crate::ViewportCommand::Screenshot
.