- 事件在系统框架的处理 默认由renderView分发后,只要Position落到View的区域,都会将View添加到监听者中
在父子同时有onTap事件时,子View添加默认放在父View前,并同时放入监听者列表中. 处理onDown事件的时候,使用addPointer为事件增加onTap回调;同样也是子在前放入GestureArenaManager中
-
事件拦截AbsorbPointer/IgnorePointer,在onDown时拦截点击事件,子View不能被添加到监听列表
-
View的add列表属于第一个layer,点击事件属于第二个layer
The gesture system in Flutter has two separate layers. The first
layer has raw pointer events that describe the location and movement
of pointers (for example, touches, mice, and styli) across the
screen. The second layer has gestures that describe semantic actions
that consist of one or more pointer movements.
- Listener 特点:
- 在onDown时添加到监听列表
- 无论move到屏幕那个地方,都能收到完整事件
- 无法中断后面的事件传递
- PointerEvent.pointer 即id
/// Unique identifier for the pointer, not reused. Changes for each
/// new pointer down event.
一般从从app启动开始,初始化为1,以后依次累加; down事件现有,后面的跟down事件id相同;
- 移动之后抬起无法触发tap事件,这一点和android的点击事件不同;
原因:_arenas会在move的时候删除相应事件 调用栈如下
GestureArenaManager._tryToResolveArena (arena.dart:233)
GestureArenaManager._resolve (arena.dart:215)
GestureArenaEntry.resolve (arena.dart:52)
OneSequenceGestureRecognizer.resolve (recognizer.dart:255)
BaseTapGestureRecognizer.resolve (tap.dart:222)
PrimaryPointerGestureRecognizer.handleEvent (recognizer.dart:464)
PointerRouter._dispatch (pointer_router.dart:76)
PointerRouter._dispatchEventToRoutes.<anonymous closure> (pointer_router.dart:117)
_LinkedHashMapMixin.forEach (compact_hash.dart:379)
PointerRouter._dispatchEventToRoutes (pointer_router.dart:115)
PointerRouter.route (pointer_router.dart:101)
GestureBinding.handleEvent (binding.dart:218)
GestureBinding.dispatchEvent (binding.dart:198)
GestureBinding._handlePointerEvent (binding.dart:156)
GestureBinding._flushPointerEventQueue (binding.dart:102)
GestureBinding._handlePointerDataPacket (binding.dart:86)
_rootRunUnary (zone.dart:1138)
_CustomZone.runUnary (zone.dart:1031)
_CustomZone.runUnaryGuarded (zone.dart:933)
_invoke1 (hooks.dart:273)
_dispatchPointerDataPacket (hooks.dart:182)