Skip to main content

InputEvent

Enum InputEvent 

Source
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.

Fields

§clicks: u8
§

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.

Fields

§delta: Vec2
§begins: bool
§

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.

Fields

§text: String
§

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.

Fields

§paths: Vec<String>
§at: Vec2
§

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.

Fields

§paths: Vec<String>
§at: Vec2
§

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

Source

pub fn mouse_down(clicks: u8) -> Self

A primary-button press — the spelling drivers and tests want when they only ever send one button.

Source

pub fn mouse_up() -> Self

A primary-button release.

Trait Implementations§

Source§

impl Clone for InputEvent

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 InputEvent

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for InputEvent

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for InputEvent

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.