pub enum InputEvent {
Show 21 variants
CursorMoved(Vec2),
CursorLeft,
MouseDown {
button: MouseButton,
clicks: u8,
},
MouseUp {
button: MouseButton,
},
Scroll(Vec2),
ScrollGesture {
delta: Vec2,
begins: bool,
},
Text(String),
Commit(String),
Paste {
text: String,
marks: ClipboardMarks,
},
Preedit(String, Option<(usize, usize)>),
Key(EditKey, Mods),
KeyDown(KeyPress),
KeyUp(KeyPress),
Access(AccessRequest),
Modifiers(KeyMods),
ForceClick(Vec2),
DragFiles {
paths: Vec<String>,
at: Vec2,
},
DropFiles {
paths: Vec<String>,
at: Vec2,
},
DragCancel,
Files(Vec<String>),
Open(Vec<String>),
}Variants§
CursorMoved(Vec2)
Logical coordinates.
CursorLeft
MouseDown
A button press. clicks is driver-measured multi-click state
(1 = single, 2 = double, 3+ = triple) — the core is clock-free, so
click timing lives with whoever owns the event loop. Only the
primary button presses, drags and clicks; see MouseButton.
MouseUp
The release of button. A non-primary release resolves nothing:
the primary button is the one that can be holding a press.
Fields
Scroll(Vec2)
Wheel/trackpad delta in logical px (positive y = scroll up), a
scroll gesture of its own: the same as
InputEvent::ScrollGesture with begins: true. What a driver
that cannot tell one gesture from the next sends, and what every
door taking a bare delta (kui_input_scroll, Node’s scroll)
feeds.
ScrollGesture
A wheel or trackpad delta that is part of a scroll gesture:
a swipe and its momentum, or a wheel spun without
a pause. begins is true on a gesture’s first event. The target
is chosen then, per axis — the innermost scroller under the
pointer that can still move that way, a scroller at its limit
passing the gesture to the one around it unless it says
overscroll: contain, an on_scroll node taking the axes its
scroll_axes names — and the rest of the gesture goes on to that
target (it is latched) wherever the pointer or the content
under it has gone since, until the next begins. An axis the
gesture had not moved on picks its target the first time it
does; a target whose node is gone, or behind a modal, is picked
again. Where gestures begin and end is the driver’s to say — the
core is clock-free: the native runner begins one after a 200 ms
pause, on a switch between a wheel’s notches and a trackpad’s
pixels, and for a wheel on a pointer move.
Text(String)
Committed text (typing, paste). Routed to the focused editor; with
none, a printable character presses or searches the focused
control. Never delivered to an onKey sink: the raw press already
reached it as a key event carrying text, and a sink hearing
both would type every character twice.
Commit(String)
Text an IME committed at the end of a composition.
Routed like Text to a focused editor; otherwise delivered to the
focused sink as {kind:"text", text, tag} — the one committed text
the platform never reports as a key press with text, so it is the
one a sink has to be told about. Drivers send Ime::Commit here and
keep typing on Text.
Paste
The clipboard’s answer to a paste the app asked for
(Core::request_paste, a menu’s Paste), with what the pasteboard
said about it. Routed exactly as InputEvent::Commit
is — a focused editor takes it as typing, a focused sink hears
{kind:"text", text, tag} — and the sink’s event gains
concealed: true and transient: true for the markers that are
set, and nothing for those that are not.
A variant of its own rather than two fields on Commit, so every
match on a commit still compiles and a driver that answers with a
bare Commit (an older C or Node host) is still an answer: both
clear the one-ask gate, and a Commit is a paste
whose pasteboard marked nothing.
Preedit(String, Option<(usize, usize)>)
In-progress IME composition (text and the caret byte range inside
it), inserted inline at the focused editor’s caret as an uncommitted
marked range: following text shifts and the paragraph rewraps.
Empty text cancels it; the commit arrives separately as Commit.
With no editor focused it goes to the focused sink as
{kind:"preedit", text, cursor: [start, end] | null, tag}, an
empty text meaning the composition ended without a commit.
Key(EditKey, Mods)
Navigation/editing key. Routed to the focused editor.
KeyDown(KeyPress)
A full key press, routed to whatever holds key focus (see
Core::set_key_focus). Apps that own their own text model take
keys through this instead of the editor path.
KeyUp(KeyPress)
The release of a key, routed the way InputEvent::KeyDown is —
so a held-key interaction (WASD, press-and-hold to preview, a key
that arms a mode) is a pair of events, not a guess about timing.
Only a key whose press was delivered produces one: a release the
focused sink never saw the press of is dropped, and focus moving
away while a key is held synthesizes the release first (see
Core::release_held_keys). The core clears text and repeat on
the way out — a release inserts nothing and never repeats.
Access(AccessRequest)
A request from assistive technology (see crate::access):
activate, focus, set an editor’s text, scroll. Resolved in the core
the way the pointer or keyboard equivalent would be, so the app
sees the same events either way.
Modifiers(KeyMods)
The physical modifier state changed. Reaches the host as a
{kind="modifiers", shift, ctrl, alt, super} event on the root (an
Elm-style app keeps it in its model and lets the view react — a
Cmd-held drag overlay, a hint bar) and is queryable while building
a frame (Ui::modifiers).
ForceClick(Vec2)
A force click at a point in logical viewport coordinates: the press deepened past the second stage of a Force Touch trackpad.
Routed like the secondary press — the topmost node under the point,
no focus moved, no caret placed, no click — because it arrives
during an ordinary press that is still running, and the click
that press produces still happens afterwards. Over text it selects
the word and asks the host to look it up; anywhere else it reaches
a node declaring on_force_click.
macOS-only in practice: no other platform winit supports reports pressure at all, and there a user can switch it off.
DragFiles
Files dragged in from the OS are over the window at at (logical
viewport coordinates) — entering and moving alike: the core tells
the two apart by whether the zone under the point changed, and a
change is the old zone’s leave then the new one’s enter.
paths are the OS paths as the driver reported them.
A repeat at the same point emits nothing.
DropFiles
The dragged files were released at at: the zone there hears
{kind="drop", phase="drop"} and nothing hears a leave; with no
zone there, nothing is emitted and whatever was lit hears its
leave.
DragCancel
The dragged files left the window, or the OS ended the drag
elsewhere: the lit zone hears its leave.
Files(Vec<String>)
A file dialog’s answer: the paths the user picked,
none for a dialog cancelled. Whoever asked with
Core::request_files hears {kind:"files", paths, tag}; with no
ask outstanding it is dropped.
Open(Vec<String>)
The OS asked the app to open these documents (backlog F124): the
Finder’s Open With, a file dropped on the Dock icon, open -a, a
double-click on a document whose type the app declares. Unlike
InputEvent::Files nothing asked for it, so it is always
delivered: the host hears {kind:"open", paths} on the root of the
window it was handed to (the main window, in the runner). paths
are file-system paths as strings; an empty list emits nothing. A
URL of a scheme of the app’s own is not a path and is not carried
here — the payload leaves room for a urls beside paths.
The macOS runner sends it, at launch (before the window opens: the paths wait for it) and while running; on Windows and Linux the documents arrive in the process’s arguments instead, and nothing sends it.
Implementations§
Source§impl InputEvent
impl InputEvent
Sourcepub fn mouse_down(clicks: u8) -> InputEvent
pub fn mouse_down(clicks: u8) -> InputEvent
A primary-button press — the spelling drivers and tests want when they only ever send one button.
Sourcepub fn mouse_up() -> InputEvent
pub fn mouse_up() -> InputEvent
A primary-button release.
Trait Implementations§
Source§impl Clone for InputEvent
impl Clone for InputEvent
Source§fn clone(&self) -> InputEvent
fn clone(&self) -> InputEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InputEvent
impl Debug for InputEvent
Source§impl PartialEq for InputEvent
impl PartialEq for InputEvent
impl StructuralPartialEq for InputEvent
Auto Trait Implementations§
impl Freeze for InputEvent
impl RefUnwindSafe for InputEvent
impl Send for InputEvent
impl Sync for InputEvent
impl Unpin for InputEvent
impl UnsafeUnpin for InputEvent
impl UnwindSafe for InputEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.