Skip to main content

Module gesture

Module gesture 

Source
Expand description

手势系统(设计文档 § 15)

  • GestureRecognizer trait + GestureState(§ 15.1)
  • 内置识别器:Tap / DoubleTap / LongPress / Pan (阶段 2 只要求 Tap + Pan;DoubleTap 纯事件驱动顺带实现; 阶段 A6 增加 LongPress — 按住超时类,由每帧 tick 时钟驱动)
  • GestureArena:多个识别器竞争同一指针,第一个 Accepted 胜出, 其余被强制 Rejected,胜出者独占后续事件(§ 15.2)
  • ProxyRenderObject:透传 RO,供 GestureDetector(已迁到 mgui-components)使用

GestureDetectorWidget 已迁移到 mgui-components crate。

已知限制(无 Ticker):

  • 双击+单击共存时,第一次单击的回调延迟到“下一次 down 且超时“ 才补触发(纯事件驱动);完整版需要计时器,等阶段 3 Ticker。
  • 同一冒泡链上多个 tap 源(如 Button 嵌 GestureDetector)会双触发; 持续型手势(Pan/DoubleTap/LongPress)则由竞技场正确仲裁。

Re-exports§

pub use crate::render_object::ProxyRenderObject;

Structs§

DoubleTapGestureRecognizer
双击识别:两次有效 tap(各自位移 ≤ slop,两次 up 间隔 ≤ 300ms) → 触发 on_double_tap。
GestureArena
多个识别器竞争同一指针:
LongPressGestureRecognizer
长按识别器:按住不动超过时长阈值触发一次回调。
PanGestureRecognizer
拖拽识别:down 后位移 > TOUCH_SLOP → Accepted(持续型手势, 竞技场胜出后独占指针),每个 move 触发 on_pan_update(delta)。
TapGestureRecognizer
单击识别:down → up 且位移 ≤ TOUCH_SLOP → 触发 on_tap

Traits§

GestureRecognizer
手势识别器(设计 § 15.1)