mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
PointerDownEvent and PointerMoveEvent default buttons
to 1 (#30579)
* Down and Move have default buttons = kPrimary.
This commit is contained in:
parent
3c605d45aa
commit
0fb6a05054
@ -8,20 +8,30 @@ import 'package:flutter/foundation.dart';
|
||||
|
||||
export 'dart:ui' show Offset, PointerDeviceKind;
|
||||
|
||||
/// The bit of [PointerEvent.buttons] that corresponds to a unified behavior of
|
||||
/// "basic operation".
|
||||
/// The bit of [PointerEvent.buttons] that corresponds to the "primary
|
||||
/// action" on any device.
|
||||
///
|
||||
/// It is equivalent to:
|
||||
/// More specifially,
|
||||
///
|
||||
/// * [kTouchContact]: The pointer contacts the touch screen.
|
||||
/// * [kStylusContact]: The stylus contacts the screen.
|
||||
/// * [kPrimaryMouseButton]: The primary mouse button.
|
||||
/// * For touch screen, it's when the pointer contacts the screen.
|
||||
/// * For stylus and inverted stylus, it's when the pen contacts the screen.
|
||||
/// * For mouse, it's when the primary button is pressed.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [kTouchContact]: an alias of this constant when used by touch screen.
|
||||
/// * [kStylusContact]: an alias of this constant when used by stylus.
|
||||
/// * [kPrimaryMouseButton]: an alias of this constant when used by mouse.
|
||||
const int kPrimaryButton = 0x01;
|
||||
|
||||
/// The bit of [PointerEvent.buttons] that corresponds to the primary mouse button.
|
||||
///
|
||||
/// The primary mouse button is typically the left button on the top of the
|
||||
/// mouse but can be reconfigured to be a different physical button.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [kTouchContact]: an alias of this constant when used by touch screen.
|
||||
const int kPrimaryMouseButton = kPrimaryButton;
|
||||
|
||||
/// The bit of [PointerEvent.buttons] that corresponds to the secondary mouse button.
|
||||
@ -32,6 +42,10 @@ const int kSecondaryMouseButton = 0x02;
|
||||
|
||||
/// The bit of [PointerEvent.buttons] that corresponds to when a stylus
|
||||
/// contacting the screen.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [kPrimaryButton]: an alias of this constant for any device.
|
||||
const int kStylusContact = kPrimaryButton;
|
||||
|
||||
/// The bit of [PointerEvent.buttons] that corresponds to the primary stylus button.
|
||||
@ -67,6 +81,10 @@ const int kForwardMouseButton = 0x10;
|
||||
|
||||
/// The bit of [PointerEvent.buttons] that corresponds to the pointer contacting
|
||||
/// a touch screen.
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [kPrimaryButton]: an alias of this constant for any device.
|
||||
const int kTouchContact = kPrimaryButton;
|
||||
|
||||
/// The bit of [PointerEvent.buttons] that corresponds to the nth mouse button.
|
||||
@ -672,7 +690,7 @@ class PointerDownEvent extends PointerEvent {
|
||||
PointerDeviceKind kind = PointerDeviceKind.touch,
|
||||
int device = 0,
|
||||
Offset position = Offset.zero,
|
||||
int buttons = 0,
|
||||
int buttons = kPrimaryButton,
|
||||
bool obscured = false,
|
||||
double pressure = 1.0,
|
||||
double pressureMin = 1.0,
|
||||
@ -727,7 +745,7 @@ class PointerMoveEvent extends PointerEvent {
|
||||
int device = 0,
|
||||
Offset position = Offset.zero,
|
||||
Offset delta = Offset.zero,
|
||||
int buttons = 0,
|
||||
int buttons = kPrimaryButton,
|
||||
bool obscured = false,
|
||||
double pressure = 1.0,
|
||||
double pressureMin = 1.0,
|
||||
|
@ -19,4 +19,18 @@ void main() {
|
||||
expect(nthMouseButton(2), kSecondaryMouseButton);
|
||||
expect(nthStylusButton(2), kSecondaryStylusButton);
|
||||
});
|
||||
|
||||
group('Default values of PointerEvents:', () {
|
||||
// Some parameters are intentionally set to a non-trivial value.
|
||||
|
||||
test('PointerDownEvent', () {
|
||||
const PointerDownEvent event = PointerDownEvent();
|
||||
expect(event.buttons, kPrimaryButton);
|
||||
});
|
||||
|
||||
test('PointerMoveEvent', () {
|
||||
const PointerMoveEvent event = PointerMoveEvent();
|
||||
expect(event.buttons, kPrimaryButton);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user