Skip to main content

SurfaceInput

Enum SurfaceInput 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

§code: KeyCode
§native: u32

The 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).

§pressed: bool
§repeat: bool
§modifiers: Modifiers
§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.

§unmodified: Option<char>

The character the key types with no modifiers held, in the keyboard’s layout: what a shortcut names it by (c for Option+C, which types ç; z for the key right of Tab on a German keyboard). None for a key that types none (Escape, an arrow, a modifier).

§

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.

Fields

§text: String
§cursor: Option<usize>
§

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.

Fields

§before: usize
§after: usize
§

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.

Fields

§position: Point
§modifiers: Modifiers
§

PointerLeft

The pointer left the surface.

§

Button

A button went down or up at position, in points from the surface’s top left.

Fields

§pressed: bool
§position: Point
§modifiers: Modifiers
§

Scroll

The wheel turned, or a trackpad scrolled. Positive: towards the end (down, right), with the user’s scrolling direction applied.

Fields

§modifiers: Modifiers
§

Motion

While the pointer is locked: how far it moved, in points, accelerated as the cursor would be.

Fields

§dx: f32
§dy: f32
§

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

Fields

§dx: f32
§dy: f32

Trait Implementations§

Source§

impl Clone for SurfaceInput

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 SurfaceInput

Source§

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

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

impl PartialEq for SurfaceInput

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 SurfaceInput

Auto Trait Implementations§

§

impl Forget for SurfaceInput

§

impl Freeze for SurfaceInput
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze,

§

impl Move for SurfaceInput

§

impl RefUnwindSafe for SurfaceInput

§

impl Send for SurfaceInput
where RawVecInner: Send,

§

impl Sync for SurfaceInput
where RawVecInner: Sync,

§

impl Unpin for SurfaceInput
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for SurfaceInput

§

impl UnwindSafe for SurfaceInput
where RawVecInner: UnwindSafe,

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> AnyEq for T
where T: Any + PartialEq,

Source§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

Source§

fn as_any(&self) -> &(dyn Any + 'static)

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