Skip to main content

WidgetEvent

Enum WidgetEvent 

Source
pub enum WidgetEvent {
Show 20 variants PointerDown(PointerData), PointerUp(PointerData), PointerMove(PointerData), PointerLeave, PointerEnter, PointerCancel, Scroll(f32, f32), KeyDown(KeyCode, KeyModifiers), KeyUp(KeyCode, KeyModifiers), FocusGained, FocusLost, FocusWithin(bool), ImeEnabled, ImeDisabled, ImePreedit(String, Option<(usize, usize)>), ImeCommit(String), SetText(String), SetValue(f32), SetExpanded { item: Option<u64>, expanded: bool, }, SetTextSelection { anchor: usize, focus: usize, },
}
Expand description

Widget 内部事件枚举

经 hit_test → Element 树冒泡。 包含:Pointer(Down/Up/Move/Leave/Enter/Scroll) / Key(Down/Up) / Focus(Gained/Lost/Within) / IME(Enabled/Disabled/Preedit/Commit) / 无障碍语义动作(SetText/SetValue/SetExpanded/SetTextSelection,定向投递不经 hit_test)。

整体 enum 只能 Clone,不能 Copy(含 String 负载)。

Variants§

§

PointerDown(PointerData)

§

PointerUp(PointerData)

§

PointerMove(PointerData)

§

PointerLeave

指针离开当前命中的 element

§

PointerEnter

指针进入新 element(可选派发,当前未使用)

§

PointerCancel

指针交互被取消(不是 Up)。

触发场景:手势竞技场选出胜者、捕获目标失效、窗口失焦/鼠标离开窗口。 收到后控件应清掉 pressed/dragging/down_pos 等瞬态,但不要触发点击。

§

Scroll(f32, f32)

滚轮/触控板滚动:(dx, dy);正 dy = 内容向上移动

§

KeyDown(KeyCode, KeyModifiers)

§

KeyUp(KeyCode, KeyModifiers)

§

FocusGained

获得焦点(发给刚被聚焦的 element)

§

FocusLost

失去焦点(发给刚失焦的 element)

§

FocusWithin(bool)

焦点进入/离开本元素子树(发给焦点目标的祖先;用于 Tooltip 聚焦展示等)

§

ImeEnabled

IME 启用(输入框聚焦后系统挂起输入法)

§

ImeDisabled

IME 停用

§

ImePreedit(String, Option<(usize, usize)>)

IME 组合中:text 是预编辑串,cursor 是光标在其中的字节偏移区间

§

ImeCommit(String)

IME 提交:text 为最终插入的文本

§

SetText(String)

无障碍 SetValue:整体替换文本输入框内容(平台语义动作,定向投递)

§

SetValue(f32)

无障碍 SetValue:设置数值控件值 ∈ [0,1](平台语义动作,定向投递)

§

SetExpanded

无障碍展开/收起:item 为虚拟项稳定 key(None = 宿主自身)

Fields

§item: Option<u64>
§expanded: bool
§

SetTextSelection

无障碍文本选区:anchor/focus 均为字符索引(不是字节偏移)

Fields

§anchor: usize
§focus: usize

Trait Implementations§

Source§

impl Clone for WidgetEvent

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 WidgetEvent

Source§

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

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

impl PartialEq for WidgetEvent

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 WidgetEvent

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