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
a5061bf9
Unverified
Commit
a5061bf9
authored
Mar 08, 2023
by
Bernardo Ferrari
Committed by
GitHub
Mar 08, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix GestureRecognizer allowedButtonsFilter. (#122227)
parent
4792f39d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
7 deletions
+29
-7
long_press.dart
packages/flutter/lib/src/gestures/long_press.dart
+2
-1
monodrag.dart
packages/flutter/lib/src/gestures/monodrag.dart
+2
-2
multidrag.dart
packages/flutter/lib/src/gestures/multidrag.dart
+2
-2
multitap.dart
packages/flutter/lib/src/gestures/multitap.dart
+2
-2
multidrag_test.dart
packages/flutter/test/gestures/multidrag_test.dart
+21
-0
No files found.
packages/flutter/lib/src/gestures/long_press.dart
View file @
a5061bf9
...
...
@@ -250,9 +250,10 @@ class LongPressGestureRecognizer extends PrimaryPointerGestureRecognizer {
super
.
postAcceptSlopTolerance
=
null
,
super
.
supportedDevices
,
super
.
debugOwner
,
super
.
allowedButtonsFilter
=
_defaultButtonAcceptBehavio
r
,
AllowedButtonsFilter
?
allowedButtonsFilte
r
,
})
:
super
(
deadline:
duration
??
kLongPressTimeout
,
allowedButtonsFilter:
allowedButtonsFilter
??
_defaultButtonAcceptBehavior
,
);
bool
_longPressAccepted
=
false
;
...
...
packages/flutter/lib/src/gestures/monodrag.dart
View file @
a5061bf9
...
...
@@ -78,8 +78,8 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
this
.
dragStartBehavior
=
DragStartBehavior
.
start
,
this
.
velocityTrackerBuilder
=
_defaultBuilder
,
super
.
supportedDevices
,
super
.
allowedButtonsFilter
=
_defaultButtonAcceptBehavio
r
,
});
AllowedButtonsFilter
?
allowedButtonsFilte
r
,
})
:
super
(
allowedButtonsFilter:
allowedButtonsFilter
??
_defaultButtonAcceptBehavior
)
;
static
VelocityTracker
_defaultBuilder
(
PointerEvent
event
)
=>
VelocityTracker
.
withKind
(
event
.
kind
);
...
...
packages/flutter/lib/src/gestures/multidrag.dart
View file @
a5061bf9
...
...
@@ -216,8 +216,8 @@ abstract class MultiDragGestureRecognizer extends GestureRecognizer {
MultiDragGestureRecognizer
({
required
super
.
debugOwner
,
super
.
supportedDevices
,
super
.
allowedButtonsFilter
=
_defaultButtonAcceptBehavio
r
,
});
AllowedButtonsFilter
?
allowedButtonsFilte
r
,
})
:
super
(
allowedButtonsFilter:
allowedButtonsFilter
??
_defaultButtonAcceptBehavior
)
;
// Accept the input if, and only if, [kPrimaryButton] is pressed.
static
bool
_defaultButtonAcceptBehavior
(
int
buttons
)
=>
buttons
==
kPrimaryButton
;
...
...
packages/flutter/lib/src/gestures/multitap.dart
View file @
a5061bf9
...
...
@@ -119,8 +119,8 @@ class DoubleTapGestureRecognizer extends GestureRecognizer {
DoubleTapGestureRecognizer
({
super
.
debugOwner
,
super
.
supportedDevices
,
super
.
allowedButtonsFilter
=
_defaultButtonAcceptBehavio
r
,
});
AllowedButtonsFilter
?
allowedButtonsFilte
r
,
})
:
super
(
allowedButtonsFilter:
allowedButtonsFilter
??
_defaultButtonAcceptBehavior
)
;
// The default value for [allowedButtonsFilter].
// Accept the input if, and only if, [kPrimaryButton] is pressed.
...
...
packages/flutter/test/gestures/multidrag_test.dart
View file @
a5061bf9
...
...
@@ -90,4 +90,25 @@ void main() {
expect
(
didStartDrag
,
isFalse
);
drag
.
dispose
();
});
test
(
'allowedButtonsFilter should work the same when null or not specified'
,
()
{
// Regression test for https://github.com/flutter/flutter/pull/122227
final
ImmediateMultiDragGestureRecognizer
recognizer1
=
ImmediateMultiDragGestureRecognizer
();
// ignore: avoid_redundant_argument_values
final
ImmediateMultiDragGestureRecognizer
recognizer2
=
ImmediateMultiDragGestureRecognizer
(
allowedButtonsFilter:
null
);
// We want to test _allowedButtonsFilter, which is called in this method.
const
PointerDownEvent
allowedPointer
=
PointerDownEvent
(
timeStamp:
Duration
(
days:
10
));
// ignore: invalid_use_of_protected_member
expect
(
recognizer1
.
isPointerAllowed
(
allowedPointer
),
true
);
// ignore: invalid_use_of_protected_member
expect
(
recognizer2
.
isPointerAllowed
(
allowedPointer
),
true
);
const
PointerDownEvent
rejectedPointer
=
PointerDownEvent
(
timeStamp:
Duration
(
days:
10
),
buttons:
kMiddleMouseButton
);
// ignore: invalid_use_of_protected_member
expect
(
recognizer1
.
isPointerAllowed
(
rejectedPointer
),
false
);
// ignore: invalid_use_of_protected_member
expect
(
recognizer2
.
isPointerAllowed
(
rejectedPointer
),
false
);
});
}
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