#[non_exhaustive]pub enum SurfaceInput {
Key {
code: KeyCode,
native: u32,
pressed: bool,
repeat: bool,
modifiers: Modifiers,
text: Option<String>,
unmodified: Option<char>,
},
Text(String),
Preedit {
text: String,
cursor: Option<usize>,
},
DeleteSurrounding {
before: usize,
after: usize,
},
PointerMoved {
position: Point,
modifiers: Modifiers,
},
PointerLeft,
Button {
button: MouseButton,
pressed: bool,
position: Point,
modifiers: Modifiers,
},
Scroll {
delta: ScrollDelta,
modifiers: Modifiers,
},
Motion {
dx: f32,
dy: f32,
},
RawMotion {
dx: f32,
dy: f32,
},
}Expand description
Input on a GpuSurface that takes it, reported as
UiEvent::SurfaceInput.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Key
A key went down, or up, while the surface had focus. repeat: the
platform’s own repeat of a key held down. On a surface that takes
text, a key an input method takes for its composition (to convert
it, choose a candidate, commit it, or start one, as a dead key does)
isn’t reported: it’s the input method’s, as in a text field.
Fields
native: u32The platform’s own code for the key: a macOS virtual key code,
a Linux evdev code, a Windows scan code (0xE0 in the high
byte for extended keys).
text: Option<String>On a surface that takes text (Prop::TextInput), what the key
typed, as the platform’s text input gives it: with Shift, Caps
Lock, AltGr or Option, and a dead key pressed before it,
composed in. None for a key that types nothing (Escape, an
arrow, a modifier, a dead key, a shortcut with Control or
Command), for a release, and on a surface that doesn’t take
text. Never control characters.
Text(String)
On a surface that takes text, text an input method committed (a composition, a candidate chosen), which no single key typed.
Preedit
On a surface that takes text, an input method’s composition in
progress (the kana typed so far, the candidate it would convert
to), for the app to draw at its caret, as a text field shows it
until it’s committed: the surface is the app’s to draw, so the
platform can’t show it there. cursor is where the composition’s
own caret is, in bytes into text. Empty when the composition ends,
committed (a Text follows) or cancelled.
DeleteSurrounding
On a surface that takes text, an input method takes back text around
the app’s caret, before and after it, in characters: text keys
typed that it now replaces (macOS’s accents, offered as a key is
held, replace the letter it typed). The app deletes it before what
comes next.
PointerMoved
The pointer moved over the surface (anywhere, while a button is held), in points from its top left. Not reported while the pointer is locked.
PointerLeft
The pointer left the surface.
Button
A button went down or up at position, in points from the
surface’s top left.
Scroll
The wheel turned, or a trackpad scrolled. Positive: towards the end (down, right), with the user’s scrolling direction applied.
Motion
While the pointer is locked: how far it moved, in points, accelerated as the cursor would be.
RawMotion
While the pointer is locked: how far the mouse moved, in the
device’s own counts, before the host’s acceleration. Reported with
Motion, for an app that applies its own (a virtual machine’s
guest, a game’s camera).