@@ -48,13 +48,22 @@ class PointerDataConverter {
48
48
// Map from browser pointer identifiers to PointerEvent pointer identifiers.
49
49
final Map <int , _PointerState > _pointers = < int , _PointerState > {};
50
50
51
+ /// This field is used to keep track of button state.
52
+ ///
53
+ /// To normalize pointer events, when we receive pointer down followed by
54
+ /// pointer up, we synthesize a move event. To make sure that button state
55
+ /// is correct for move regardless of button state at the time of up event
56
+ /// we store it on down,hover and move events.
57
+ int _activeButtons = 0 ;
58
+
51
59
/// Clears the existing pointer states.
52
60
///
53
61
/// This method is invoked during hot reload to make sure we have a clean
54
62
/// converter after hot reload.
55
63
void clearPointerState () {
56
64
_pointers.clear ();
57
65
_PointerState ._pointerCount = 0 ;
66
+ _activeButtons = 0 ;
58
67
}
59
68
60
69
_PointerState _ensureStateForPointer (int device, double x, double y) {
@@ -328,6 +337,7 @@ class PointerDataConverter {
328
337
scrollDeltaY: scrollDeltaY,
329
338
)
330
339
);
340
+ _activeButtons = buttons;
331
341
break ;
332
342
case ui.PointerChange .down:
333
343
final bool alreadyAdded = _pointers.containsKey (device);
@@ -426,6 +436,7 @@ class PointerDataConverter {
426
436
scrollDeltaY: scrollDeltaY,
427
437
)
428
438
);
439
+ _activeButtons = buttons;
429
440
break ;
430
441
case ui.PointerChange .move:
431
442
assert (_pointers.containsKey (device));
@@ -459,6 +470,7 @@ class PointerDataConverter {
459
470
scrollDeltaY: scrollDeltaY,
460
471
)
461
472
);
473
+ _activeButtons = buttons;
462
474
break ;
463
475
case ui.PointerChange .up:
464
476
case ui.PointerChange .cancel:
@@ -485,7 +497,7 @@ class PointerDataConverter {
485
497
device: device,
486
498
physicalX: physicalX,
487
499
physicalY: physicalY,
488
- buttons: buttons ,
500
+ buttons: _activeButtons ,
489
501
obscured: obscured,
490
502
pressure: pressure,
491
503
pressureMin: pressureMin,
0 commit comments