| OLD | NEW |
| 1 Pointer Events | 1 Pointer Events |
| 2 ============== | 2 ============== |
| 3 | 3 |
| 4 Scope | 4 Scope |
| 5 ----- | 5 ----- |
| 6 | 6 |
| 7 The following input devices are supported by sky: | 7 The following input devices are supported by sky: |
| 8 - fingers on multitouch screens | 8 - fingers on multitouch screens |
| 9 - mice, including mouse wheels | 9 - mice, including mouse wheels |
| 10 - styluses on screens | 10 - styluses on screens |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 ...or: | 175 ...or: |
| 176 - move +1, down, move +14 | 176 - move +1, down, move +14 |
| 177 | 177 |
| 178 TODO(ianh): expose the unfiltered uncoalesced stream of events for | 178 TODO(ianh): expose the unfiltered uncoalesced stream of events for |
| 179 programs that want more precision (e.g. drawing apps) | 179 programs that want more precision (e.g. drawing apps) |
| 180 | 180 |
| 181 | 181 |
| 182 These events have the following fields (see below for the class | 182 These events have the following fields (see below for the class |
| 183 definitions): | 183 definitions): |
| 184 | 184 |
| 185 pointer: an integer assigned to this touch or pointer when it | 185 pointer: an integer assigned to this touch or pointer when it |
| 186 enters the system, never reused, increasing | 186 enters the system, never reused, increasing |
| 187 monotonically every time a new value is assigned, | 187 monotonically every time a new value is assigned, |
| 188 starting from 1 (if the system gets a new tap every | 188 starting from 1 (if the system gets a new tap every |
| 189 microsecond, this will cause a problem after 285 | 189 microsecond, this will cause a problem after 285 |
| 190 years) | 190 years) |
| 191 | 191 |
| 192 kind: one of 'touch', 'mouse', 'stylus', 'inverted-stylus' | 192 kind: one of 'touch', 'mouse', 'stylus', 'inverted-stylus' |
| 193 | 193 |
| 194 x: x-position relative to the top-left corner of the | 194 x: x-position relative to the top-left corner of the |
| 195 surface of the node on which the event was fired | 195 surface of the node on which the event was fired |
| 196 | 196 |
| 197 y: y-position relative to the top-left corner of the | 197 y: y-position relative to the top-left corner of the |
| 198 surface of the node on which the event was fired | 198 surface of the node on which the event was fired |
| 199 | 199 |
| 200 dx: difference in x-position since last | 200 dx: difference in x-position since last |
| 201 ``PointerMovedEvent`` event | 201 ``PointerMovedEvent`` event |
| 202 | 202 |
| 203 dy: difference in y-position since last | 203 dy: difference in y-position since last |
| 204 ``PointerMovedEvent`` event | 204 ``PointerMovedEvent`` event |
| 205 | 205 |
| 206 buttons: a bitfield of the buttons pressed, from the following | 206 buttons: a bitfield of the buttons pressed, from the following |
| 207 list: | 207 list: |
| 208 | 208 |
| 209 1: primary mouse button (not available on stylus) | 209 1: primary mouse button (not available on stylus) |
| 210 | 210 |
| 211 2: secondary mouse button, primary stylus button | 211 2: secondary mouse button, primary stylus button |
| 212 | 212 |
| 213 3: middle mouse button, secondary stylus button | 213 3: middle mouse button, secondary stylus button |
| 214 | 214 |
| 215 4: back button | 215 4: back button |
| 216 | 216 |
| 217 5: forward button | 217 5: forward button |
| 218 | 218 |
| 219 additional buttons can be represented by numbers | 219 additional buttons can be represented by numbers |
| 220 greater than six: | 220 greater than six: |
| 221 | 221 |
| 222 n: (n-2)th mouse button, ignoring any buttons that | 222 n: (n-2)th mouse button, ignoring any buttons that |
| 223 are explicitly back or forward buttons | 223 are explicitly back or forward buttons |
| 224 | 224 |
| 225 (n-4)th stylus button, again ignoring any | 225 (n-4)th stylus button, again ignoring any |
| 226 explictly back or forward buttons | 226 explictly back or forward buttons |
| 227 | 227 |
| 228 note that stylus buttons can be pressed even when the | 228 note that stylus buttons can be pressed even when the |
| 229 pointer is not "down" | 229 pointer is not "down" |
| 230 | 230 |
| 231 e.g. if the left mouse button and the right mouse | 231 e.g. if the left mouse button and the right mouse |
| 232 button are pressed at the same time, the value will | 232 button are pressed at the same time, the value will |
| 233 be 3 (bits 1 and 2); if the right mouse button and | 233 be 3 (bits 1 and 2); if the right mouse button and |
| 234 the back button are pressed at the same time, the | 234 the back button are pressed at the same time, the |
| 235 value will be 10 (bits 2 and 4) | 235 value will be 10 (bits 2 and 4) |
| 236 | 236 |
| 237 down: true if the pointer is down (in ``PointerDownEvent`` | 237 down: true if the pointer is down (in ``PointerDownEvent`` |
| 238 event or subsequent ``PointerMoveEvent`` events); | 238 event or subsequent ``PointerMoveEvent`` events); |
| 239 false otherwise (in ``PointerAdded``, ``PointerUp``, | 239 false otherwise (in ``PointerAdded``, ``PointerUp``, |
| 240 and ``PointerRemovedEvent`` events, and in | 240 and ``PointerRemovedEvent`` events, and in |
| 241 ``PointerMoveEvent`` events that aren't between | 241 ``PointerMoveEvent`` events that aren't between |
| 242 ``PointerDownEvent`` and ``PointerUpEvent`` events) | 242 ``PointerDownEvent`` and ``PointerUpEvent`` events) |
| 243 | 243 |
| 244 primary: true if this is a primary pointer/touch (see above) | 244 primary: true if this is a primary pointer/touch (see above) |
| 245 can only be set for ``PointerMovedEvent`` and | 245 can only be set for ``PointerMovedEvent`` and |
| 246 ``PointerUpEvent`` | 246 ``PointerUpEvent`` |
| 247 | 247 |
| 248 obscured: true if the system was rendering another view on top | 248 obscured: true if the system was rendering another view on top |
| 249 of the sky application at the time of the event (this | 249 of the sky application at the time of the event (this |
| 250 is intended to enable click-jacking protections) | 250 is intended to enable click-jacking protections) |
| 251 | 251 |
| 252 | 252 |
| 253 When down is true: | 253 When down is true: |
| 254 | 254 |
| 255 pressure: the pressure of the touch as a number ranging from | 255 pressure: the pressure of the touch as a number ranging from |
| 256 0.0, indicating a touch with no discernible pressure, | 256 0.0, indicating a touch with no discernible pressure, |
| 257 to 1.0, indicating a touch with "normal" pressure, | 257 to 1.0, indicating a touch with "normal" pressure, |
| 258 and possibly beyond, indicating a stronger touch; for | 258 and possibly beyond, indicating a stronger touch; for |
| 259 devices that do not detect pressure (e.g. mice), | 259 devices that do not detect pressure (e.g. mice), |
| 260 returns 1.0 | 260 returns 1.0 |
| 261 | 261 |
| 262 pressure-min: the minimum value that pressure can return for this | 262 pressure-min: the minimum value that pressure can return for this |
| 263 pointer | 263 pointer |
| 264 | 264 |
| 265 pressure-max: the maximum value that pressure can return for this | 265 pressure-max: the maximum value that pressure can return for this |
| 266 pointer | 266 pointer |
| 267 | 267 |
| 268 | 268 |
| 269 When kind is 'touch', 'stylus', or 'stylus-inverted': | 269 When kind is 'touch', 'stylus', or 'stylus-inverted': |
| 270 | 270 |
| 271 distance: distance of detected object from surface (e.g. | 271 distance: distance of detected object from surface (e.g. |
| 272 distance of stylus or finger from screen), if | 272 distance of stylus or finger from screen), if |
| 273 supported and down is not true, otherwise 0.0. | 273 supported and down is not true, otherwise 0.0. |
| 274 | 274 |
| 275 distance-min: the minimum value that distance can return for this | 275 distance-min: the minimum value that distance can return for this |
| 276 pointer (always 0.0) | 276 pointer (always 0.0) |
| 277 | 277 |
| 278 distance-max: the maximum value that distance can return for this | 278 distance-max: the maximum value that distance can return for this |
| 279 pointer (0.0 if not supported) | 279 pointer (0.0 if not supported) |
| 280 | 280 |
| 281 | 281 |
| 282 When kind is 'touch', 'stylus', or 'stylus-inverted' and down is true: | 282 When kind is 'touch', 'stylus', or 'stylus-inverted' and down is true: |
| 283 | 283 |
| 284 radius-major: the radius of the contact ellipse along the major | 284 radius-major: the radius of the contact ellipse along the major |
| 285 axis, in pixels | 285 axis, in pixels |
| 286 | 286 |
| 287 radius-minor: the radius of the contact ellipse along the major | 287 radius-minor: the radius of the contact ellipse along the major |
| 288 axis, in pixels | 288 axis, in pixels |
| 289 | 289 |
| 290 radius-min: the minimum value that could be reported for | 290 radius-min: the minimum value that could be reported for |
| 291 radius-major or radius-minor for this pointer | 291 radius-major or radius-minor for this pointer |
| 292 | 292 |
| 293 radius-max: the maximum value that could be reported for | 293 radius-max: the maximum value that could be reported for |
| 294 radius-major or radius-minor for this pointer | 294 radius-major or radius-minor for this pointer |
| 295 | 295 |
| 296 | 296 |
| 297 When kind is 'touch' and down is true: | 297 When kind is 'touch' and down is true: |
| 298 | 298 |
| 299 orientation: the angle of the contact ellipse, in radians in the | 299 orientation: the angle of the contact ellipse, in radians in the |
| 300 range | 300 range |
| 301 | 301 |
| 302 -pi/2 < orientation <= pi/2 | 302 -pi/2 < orientation <= pi/2 |
| 303 | 303 |
| 304 ...giving the angle of the major axis of the ellipse | 304 ...giving the angle of the major axis of the ellipse |
| 305 with the y-axis (negative angles indicating an | 305 with the y-axis (negative angles indicating an |
| 306 orientation along the top-left / bottom-right | 306 orientation along the top-left / bottom-right |
| 307 diagonal, positive angles indicating an orientation | 307 diagonal, positive angles indicating an orientation |
| 308 along the top-right / bottom-left diagonal, and zero | 308 along the top-right / bottom-left diagonal, and zero |
| 309 indicating an orientation parallel with the y-axis) | 309 indicating an orientation parallel with the y-axis) |
| 310 | 310 |
| 311 | 311 |
| 312 When kind is 'stylus' or 'stylus-inverted': | 312 When kind is 'stylus' or 'stylus-inverted': |
| 313 | 313 |
| 314 orientation: the angle of the stylus, in radians in the range | 314 orientation: the angle of the stylus, in radians in the range |
| 315 | 315 |
| 316 -pi < orientation <= pi | 316 -pi < orientation <= pi |
| 317 | 317 |
| 318 ...giving the angle of the axis of the stylus | 318 ...giving the angle of the axis of the stylus |
| 319 projected onto the screen, relative to the positive | 319 projected onto the screen, relative to the positive |
| 320 y-axis of the screen (thus 0 indicates the stylus, if | 320 y-axis of the screen (thus 0 indicates the stylus, if |
| 321 projected onto the screen, would go from the contact | 321 projected onto the screen, would go from the contact |
| 322 point vertically up in the positive y-axis direction, | 322 point vertically up in the positive y-axis direction, |
| 323 pi would indicate that the stylus would go down in | 323 pi would indicate that the stylus would go down in |
| 324 the negative y-axis direction; pi/4 would indicate | 324 the negative y-axis direction; pi/4 would indicate |
| 325 that the stylus goes up and to the right, -pi/2 would | 325 that the stylus goes up and to the right, -pi/2 would |
| 326 indicate that the stylus goes to the left, etc) | 326 indicate that the stylus goes to the left, etc) |
| 327 | 327 |
| 328 tilt: the angle of the stylus, in radians in the range | 328 tilt: the angle of the stylus, in radians in the range |
| 329 | 329 |
| 330 0 <= tilt <= pi/2 | 330 0 <= tilt <= pi/2 |
| 331 | 331 |
| 332 ...giving the angle of the axis of the stylus, | 332 ...giving the angle of the axis of the stylus, |
| 333 relative to the axis perpendicular to the screen | 333 relative to the axis perpendicular to the screen |
| 334 (thus 0 indicates the stylus is orthogonal to the | 334 (thus 0 indicates the stylus is orthogonal to the |
| 335 plane of the screen, while pi/2 indicates that the | 335 plane of the screen, while pi/2 indicates that the |
| 336 stylus is flat on the screen) | 336 stylus is flat on the screen) |
| 337 | 337 |
| 338 | 338 |
| 339 TODO(ianh): add an API that exposes the currently existing pointers, | 339 TODO(ianh): add an API that exposes the currently existing pointers, |
| 340 so that you can determine e.g. if you have a mouse. | 340 so that you can determine e.g. if you have a mouse. |
| 341 | 341 |
| 342 Here are the class definitions for pointer events: | 342 Here are the class definitions for pointer events: |
| 343 | 343 |
| 344 ```dart | 344 ```dart |
| 345 enum PointerKind { touch, mouse, stylus, invertedStylus } | 345 enum PointerKind { touch, mouse, stylus, invertedStylus } |
| 346 | 346 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 } | 433 } |
| 434 ``` | 434 ``` |
| 435 | 435 |
| 436 Wheel events | 436 Wheel events |
| 437 ------------ | 437 ------------ |
| 438 | 438 |
| 439 When a wheel input device is turned, a ``WheelEvent`` event that | 439 When a wheel input device is turned, a ``WheelEvent`` event that |
| 440 doesn't bubble is fired at the application's document, with the | 440 doesn't bubble is fired at the application's document, with the |
| 441 following fields: | 441 following fields: |
| 442 | 442 |
| 443 wheel: an integer assigned to this wheel by the system. The | 443 wheel: an integer assigned to this wheel by the system. The |
| 444 same wheel on the same system must always be given | 444 same wheel on the same system must always be given |
| 445 the same ID. The primary wheel (e.g. the vertical | 445 the same ID. The primary wheel (e.g. the vertical |
| 446 wheel on a mouse) must be given ID 1. | 446 wheel on a mouse) must be given ID 1. |
| 447 | 447 |
| 448 delta: an floating point number representing the fraction of | 448 delta: an floating point number representing the fraction of |
| 449 the wheel that was turned, with positive numbers | 449 the wheel that was turned, with positive numbers |
| 450 representing a downward movement on vertical wheels, | 450 representing a downward movement on vertical wheels, |
| 451 rightward movement on horizontal wheels, and a | 451 rightward movement on horizontal wheels, and a |
| 452 clockwise movement on wheels with a user-facing side. | 452 clockwise movement on wheels with a user-facing side. |
| 453 | 453 |
| 454 Additionally, if the wheel is associated with a pointer (e.g. a mouse | 454 Additionally, if the wheel is associated with a pointer (e.g. a mouse |
| 455 wheel), the following fields must be present also: | 455 wheel), the following fields must be present also: |
| 456 | 456 |
| 457 pointer: the integer assigned to the pointer in its | 457 pointer: the integer assigned to the pointer in its |
| 458 ``PointerAddEvent`` event (see above). | 458 ``PointerAddEvent`` event (see above). |
| 459 | 459 |
| 460 x: x-position relative to the top-left corner of the | 460 x: x-position relative to the top-left corner of the |
| 461 display, in global layout coordinates | 461 display, in global layout coordinates |
| 462 | 462 |
| 463 y: x-position relative to the top-left corner of the | 463 y: x-position relative to the top-left corner of the |
| 464 display, in global layout coordinates | 464 display, in global layout coordinates |
| 465 | 465 |
| 466 Note: The only wheels that are supported are mouse wheels and physical | 466 Note: The only wheels that are supported are mouse wheels and physical |
| 467 dials. Track balls are not reported as mouse wheels. | 467 dials. Track balls are not reported as mouse wheels. |
| 468 | 468 |
| 469 ```dart | 469 ```dart |
| 470 class WheelEvent extends Event { | 470 class WheelEvent extends Event { |
| 471 PointerEvent({ bool bubbles, | 471 PointerEvent({ bool bubbles, |
| 472 this.wheel, | 472 this.wheel, |
| 473 this.delta: 0.0, | 473 this.delta: 0.0, |
| 474 this.pointer, | 474 this.pointer, |
| 475 this.x, this.y, | 475 this.x, this.y, |
| 476 }): super(bubbles: bubbles); | 476 }): super(bubbles: bubbles); |
| 477 | 477 |
| 478 final int wheel; | 478 final int wheel; |
| 479 final double delta; // revolutions (or fractions thereof) | 479 final double delta; // revolutions (or fractions thereof) |
| 480 final int pointer; | 480 final int pointer; |
| 481 final double x; // logical pixels | 481 final double x; // logical pixels |
| 482 final double y; // logical pixels | 482 final double y; // logical pixels |
| 483 | 483 |
| 484 bool get bubbles => false; | 484 bool get bubbles => false; |
| 485 } | 485 } |
| 486 ``` | 486 ``` |
| OLD | NEW |