Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
0fb6a050
Unverified
Commit
0fb6a050
authored
Apr 22, 2019
by
Tong Mu
Committed by
GitHub
Apr 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PointerDownEvent and PointerMoveEvent default `buttons` to 1 (#30579)
* Down and Move have default buttons = kPrimary.
parent
3c605d45
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
8 deletions
+40
-8
events.dart
packages/flutter/lib/src/gestures/events.dart
+26
-8
events_test.dart
packages/flutter/test/gestures/events_test.dart
+14
-0
No files found.
packages/flutter/lib/src/gestures/events.dart
View file @
0fb6a050
...
...
@@ -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
,
...
...
packages/flutter/test/gestures/events_test.dart
View file @
0fb6a050
...
...
@@ -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
);
});
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment