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
e912b91c
Unverified
Commit
e912b91c
authored
Jan 13, 2022
by
chunhtai
Committed by
GitHub
Jan 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Supported devices to the TapGestureRecognizer (#96560)
parent
9c231067
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
3 deletions
+86
-3
tap.dart
packages/flutter/lib/src/gestures/tap.dart
+8
-3
tap_test.dart
packages/flutter/test/gestures/tap_test.dart
+78
-0
No files found.
packages/flutter/lib/src/gestures/tap.dart
View file @
e912b91c
...
...
@@ -136,8 +136,10 @@ typedef GestureTapCancelCallback = void Function();
/// any buttons.
abstract
class
BaseTapGestureRecognizer
extends
PrimaryPointerGestureRecognizer
{
/// Creates a tap gesture recognizer.
BaseTapGestureRecognizer
({
Object
?
debugOwner
})
:
super
(
deadline:
kPressTimeout
,
debugOwner:
debugOwner
);
///
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
BaseTapGestureRecognizer
({
Object
?
debugOwner
,
Set
<
PointerDeviceKind
>?
supportedDevices
})
:
super
(
deadline:
kPressTimeout
,
debugOwner:
debugOwner
,
supportedDevices:
supportedDevices
);
bool
_sentTapDown
=
false
;
bool
_wonArenaForPrimaryPointer
=
false
;
...
...
@@ -346,7 +348,10 @@ abstract class BaseTapGestureRecognizer extends PrimaryPointerGestureRecognizer
/// * [MultiTapGestureRecognizer]
class
TapGestureRecognizer
extends
BaseTapGestureRecognizer
{
/// Creates a tap gesture recognizer.
TapGestureRecognizer
({
Object
?
debugOwner
})
:
super
(
debugOwner:
debugOwner
);
///
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
TapGestureRecognizer
({
Object
?
debugOwner
,
Set
<
PointerDeviceKind
>?
supportedDevices
})
:
super
(
debugOwner:
debugOwner
,
supportedDevices:
supportedDevices
);
/// A pointer has contacted the screen at a particular location with a primary
/// button, which might be the start of a tap.
...
...
packages/flutter/test/gestures/tap_test.dart
View file @
e912b91c
...
...
@@ -119,6 +119,84 @@ void main() {
tap
.
dispose
();
});
testGesture
(
'Should recognize tap for supported devices only'
,
(
GestureTester
tester
)
{
final
TapGestureRecognizer
tap
=
TapGestureRecognizer
(
supportedDevices:
<
PointerDeviceKind
>{
PointerDeviceKind
.
mouse
,
PointerDeviceKind
.
stylus
},
);
bool
tapRecognized
=
false
;
tap
.
onTap
=
()
{
tapRecognized
=
true
;
};
const
PointerDownEvent
touchDown
=
PointerDownEvent
(
pointer:
1
,
position:
Offset
(
10.0
,
10.0
),
);
const
PointerUpEvent
touchUp
=
PointerUpEvent
(
pointer:
1
,
position:
Offset
(
11.0
,
9.0
),
);
tap
.
addPointer
(
touchDown
);
tester
.
closeArena
(
1
);
expect
(
tapRecognized
,
isFalse
);
tester
.
route
(
touchDown
);
expect
(
tapRecognized
,
isFalse
);
tester
.
route
(
touchUp
);
expect
(
tapRecognized
,
isFalse
);
GestureBinding
.
instance
!.
gestureArena
.
sweep
(
1
);
expect
(
tapRecognized
,
isFalse
);
const
PointerDownEvent
mouseDown
=
PointerDownEvent
(
kind:
PointerDeviceKind
.
mouse
,
pointer:
1
,
position:
Offset
(
10.0
,
10.0
),
);
const
PointerUpEvent
mouseUp
=
PointerUpEvent
(
kind:
PointerDeviceKind
.
mouse
,
pointer:
1
,
position:
Offset
(
11.0
,
9.0
),
);
tap
.
addPointer
(
mouseDown
);
tester
.
closeArena
(
1
);
expect
(
tapRecognized
,
isFalse
);
tester
.
route
(
mouseDown
);
expect
(
tapRecognized
,
isFalse
);
tester
.
route
(
mouseUp
);
expect
(
tapRecognized
,
isTrue
);
GestureBinding
.
instance
!.
gestureArena
.
sweep
(
1
);
expect
(
tapRecognized
,
isTrue
);
tapRecognized
=
false
;
const
PointerDownEvent
stylusDown
=
PointerDownEvent
(
kind:
PointerDeviceKind
.
stylus
,
pointer:
1
,
position:
Offset
(
10.0
,
10.0
),
);
const
PointerUpEvent
stylusUp
=
PointerUpEvent
(
kind:
PointerDeviceKind
.
stylus
,
pointer:
1
,
position:
Offset
(
11.0
,
9.0
),
);
tap
.
addPointer
(
stylusDown
);
tester
.
closeArena
(
1
);
expect
(
tapRecognized
,
isFalse
);
tester
.
route
(
stylusDown
);
expect
(
tapRecognized
,
isFalse
);
tester
.
route
(
stylusUp
);
expect
(
tapRecognized
,
isTrue
);
GestureBinding
.
instance
!.
gestureArena
.
sweep
(
1
);
expect
(
tapRecognized
,
isTrue
);
tap
.
dispose
();
});
testGesture
(
'Details contain the correct device kind'
,
(
GestureTester
tester
)
{
final
TapGestureRecognizer
tap
=
TapGestureRecognizer
();
...
...
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