Skip to main content

InputEvent

Enum InputEvent 

Source
pub enum InputEvent {
Show 29 variants PointerDown { x: i16, y: i16, }, PointerMove { x: i16, y: i16, }, PointerUp { x: i16, y: i16, }, PointerSecondaryDown { x: i16, y: i16, }, PointerSecondaryUp { x: i16, y: i16, }, PointerLeave, PointerCancel, PointerKindChanged(PointerKind), Scroll { x: i16, y: i16, delta_y: i16, }, ScrollX { x: i16, y: i16, delta_x: i16, }, KeyDown(KeyCode), KeyUp(KeyCode), ModifiersChanged(KeyModifiers), Backspace, Delete, TextCommit(char), ImeEnabled, ImeDisabled, ImePreedit(ImePreedit), NavigateBack, SafeAreaChanged(SafeAreaInsets), KeyboardInsetChanged(i16), Pinch { x: i16, y: i16, delta_scale_x1000: i16, }, Rotate { x: i16, y: i16, delta_deg10: i16, }, ScrollPixel { x: i16, y: i16, dx: i16, dy: i16, }, FileHovered { x: i16, y: i16, }, FileDropped { x: i16, y: i16, }, FileHoverCancelled, SystemThemeChanged { dark: bool, },
}
Expand description

统一输入事件枚举(支持完整触摸手势生命周期、滚轮、物理按键焦点导航、原生 IME 组合输入、移动端安全区与系统返回)。

Variants§

§

PointerDown

指针/手指按下。

Fields

§

PointerMove

指针/手指移动或拖拽。

Fields

§

PointerUp

指针/手指抬起。

Fields

§

PointerSecondaryDown

鼠标右键(次键)按下。

Fields

§

PointerSecondaryUp

鼠标右键(次键)抬起。

Fields

§

PointerLeave

指针移出当前窗口/表面区域(清除悬停状态)。

§

PointerCancel

指针/手势取消。

§

PointerKindChanged(PointerKind)

更新当前指针输入设备来源类型(区分桌面 Mouse / Pen 与触控屏 Touch)。

§

Scroll

鼠标滚轮或编码器滚动。

Fields

§delta_y: i16
§

ScrollX

水平滚轮滚动。

Fields

§delta_x: i16
§

KeyDown(KeyCode)

物理按键或旋钮按键按下。

§

KeyUp(KeyCode)

物理按键释放。

§

ModifiersChanged(KeyModifiers)

键盘修饰键状态变更(Ctrl / Alt / Shift / Super)。

§

Backspace

退格删除一个字符(面向处于聚焦态的文本输入框)。

§

Delete

删除光标后一个字符(Delete 键)。

§

TextCommit(char)

输入法(IME)提交单个字符。

§

ImeEnabled

系统输入法(IME)会话激活。

§

ImeDisabled

系统输入法(IME)会话关闭/失焦(清空预编辑态)。

§

ImePreedit(ImePreedit)

系统输入法(IME)组合输入预编辑文本更新(如拼音 "zhongwen" 及选区光标)。

§

NavigateBack

系统级返回导航请求(Android 返回键 / 预测性返回手势 / iOS 左边缘右滑返回 / Web 浏览器 popstate)。

§

SafeAreaChanged(SafeAreaInsets)

移动端异形屏安全区域发生变更(如屏幕旋转、状态栏显隐切换)。

§

KeyboardInsetChanged(i16)

移动端屏幕软键盘弹出高度发生变更(0 表示软键盘收起)。

§

Pinch

双指捏合/触控板缩放手势(delta_scale_x1000 为千分比增量,如 +50 表示放大 5%)。

Fields

§delta_scale_x1000: i16
§

Rotate

双指旋转手势(delta_deg10 单位 0.1° 顺时针增量)。

Fields

§delta_deg10: i16
§

ScrollPixel

触控板高精度像素级双轴平滑滚动。

Fields

§dx: i16
§dy: i16
§

FileHovered

外部 OS 文件拖拽悬停在窗口上方。

Fields

§

FileDropped

外部 OS 文件在窗口指定坐标处放下(路径列表通过引擎 dropped_files() 读取)。

Fields

§

FileHoverCancelled

外部 OS 文件拖拽离开窗口取消。

§

SystemThemeChanged

操作系统深浅色主题热切换通知。

Fields

§dark: bool

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 Copy for InputEvent

Source§

impl Debug for InputEvent

Source§

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

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

impl Eq for InputEvent

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> FluentBuilder for T

Source§

fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self

当 condition 为 true 时执行闭包修饰自身,否则原样返回。
Source§

fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self

根据 condition 在两个修饰分支之间二选一。
Source§

fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self

当 option 为 Some(value) 时执行闭包修饰自身,否则原样返回。
Source§

fn when_none<O>( self, option: &Option<O>, then: impl FnOnce(Self) -> Self, ) -> Self

当 option 为 None 时执行闭包修饰自身,否则原样返回。
Source§

fn apply<U>(self, f: impl FnOnce(Self) -> U) -> U

通用管道映射变换(避免与 Iterator::map / Option::map 重名)。
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.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,