Skip to content

Commit be8cb49

Browse files
authored
Document PointerChange and PointerDeviceKind (flutter#34059)
1 parent 4232607 commit be8cb49

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

lib/ui/pointer.dart

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,50 @@ enum PointerChange {
3838
up,
3939

4040
/// A pan/zoom has started on this pointer.
41+
///
42+
/// This type of event will always have kind [PointerDeviceKind.trackpad].
4143
panZoomStart,
4244

4345
/// The pan/zoom on this pointer has updated.
46+
///
47+
/// This type of event will always have kind [PointerDeviceKind.trackpad].
4448
panZoomUpdate,
4549

4650
/// The pan/zoom on this pointer has ended.
51+
///
52+
/// This type of event will always have kind [PointerDeviceKind.trackpad].
4753
panZoomEnd,
4854
}
4955

5056
/// The kind of pointer device.
5157
enum PointerDeviceKind {
5258
/// A touch-based pointer device.
59+
///
60+
/// The most common case is a touch screen.
61+
///
62+
/// When the user is operating with a trackpad on iOS, clicking will also
63+
/// dispatch events with kind [touch] if
64+
/// `UIApplicationSupportsIndirectInputEvents` is not present in `Info.plist`
65+
/// or returns NO.
66+
///
67+
/// See also:
68+
///
69+
/// * [UIApplicationSupportsIndirectInputEvents](https://developer.apple.com/documentation/bundleresources/information_property_list/uiapplicationsupportsindirectinputevents?language=objc).
5370
touch,
5471

5572
/// A mouse-based pointer device.
73+
///
74+
/// The most common case is a mouse on the desktop or Web.
75+
///
76+
/// When the user is operating with a trackpad on iOS, moving the pointing
77+
/// cursor will also dispatch events with kind [mouse], and clicking will
78+
/// dispatch events with kind [mouse] if
79+
/// `UIApplicationSupportsIndirectInputEvents` is not present in `Info.plist`
80+
/// or returns NO.
81+
///
82+
/// See also:
83+
///
84+
/// * [UIApplicationSupportsIndirectInputEvents](https://developer.apple.com/documentation/bundleresources/information_property_list/uiapplicationsupportsindirectinputevents?language=objc).
5685
mouse,
5786

5887
/// A pointer device with a stylus.
@@ -61,7 +90,31 @@ enum PointerDeviceKind {
6190
/// A pointer device with a stylus that has been inverted.
6291
invertedStylus,
6392

64-
/// A touch-based pointer device with an indirect surface.
93+
/// Gestures from a trackpad.
94+
///
95+
/// A trackpad here is defined as a touch-based pointer device with an
96+
/// indirect surface (the user operates the screen by touching something that
97+
/// is not the screen).
98+
///
99+
/// When the user makes zoom, pan, scroll or rotate gestures with a physical
100+
/// trackpad, supporting platforms dispatch events with kind [trackpad].
101+
///
102+
/// Events with kind [trackpad] can only have a [PointerChange] of `add`,
103+
/// `remove`, and pan-zoom related values.
104+
///
105+
/// Some platforms don't support (or don't fully support) trackpad
106+
/// gestures, and might convert trackpad gestures into fake pointer events
107+
/// that simulate dragging. These events typically have kind [touch] or
108+
/// [mouse] instead of [trackpad]. This includes (but is not limited to) Web,
109+
/// and iOS when `UIApplicationSupportsIndirectInputEvents` isn't present in
110+
/// `Info.plist` or returns NO.
111+
///
112+
/// Moving the pointing cursor or clicking with a trackpad typically triggers
113+
/// [touch] or [mouse] events, but never triggers [trackpad] events.
114+
///
115+
/// See also:
116+
///
117+
/// * [UIApplicationSupportsIndirectInputEvents](https://developer.apple.com/documentation/bundleresources/information_property_list/uiapplicationsupportsindirectinputevents?language=objc).
65118
trackpad,
66119

67120
/// An unknown pointer device.

0 commit comments

Comments
 (0)