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
3acc2785
Unverified
Commit
3acc2785
authored
Aug 17, 2018
by
Ian Hickson
Committed by
GitHub
Aug 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Documentation regarding tap gesture callbacks (#20647)
parent
9118d3d7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
1 deletion
+100
-1
arena.dart
packages/flutter/lib/src/gestures/arena.dart
+1
-1
tap.dart
packages/flutter/lib/src/gestures/tap.dart
+81
-0
gesture_detector.dart
packages/flutter/lib/src/widgets/gesture_detector.dart
+18
-0
No files found.
packages/flutter/lib/src/gestures/arena.dart
View file @
3acc2785
...
@@ -92,7 +92,7 @@ class _GestureArena {
...
@@ -92,7 +92,7 @@ class _GestureArena {
}
}
}
}
/// The first member to accept or the last member to not
to
reject wins.
/// The first member to accept or the last member to not reject wins.
///
///
/// See [https://flutter.io/gestures/#gesture-disambiguation] for more
/// See [https://flutter.io/gestures/#gesture-disambiguation] for more
/// information about the role this class plays in the gesture system.
/// information about the role this class plays in the gesture system.
...
...
packages/flutter/lib/src/gestures/tap.dart
View file @
3acc2785
...
@@ -10,6 +10,11 @@ import 'events.dart';
...
@@ -10,6 +10,11 @@ import 'events.dart';
import
'recognizer.dart'
;
import
'recognizer.dart'
;
/// Details for [GestureTapDownCallback], such as position.
/// Details for [GestureTapDownCallback], such as position.
///
/// See also:
///
/// * [GestureDetector.onTapDown], which receives this information.
/// * [TapGestureRecognizer], which passes this information to one of its callbacks.
class
TapDownDetails
{
class
TapDownDetails
{
/// Creates details for a [GestureTapDownCallback].
/// Creates details for a [GestureTapDownCallback].
///
///
...
@@ -26,9 +31,19 @@ class TapDownDetails {
...
@@ -26,9 +31,19 @@ class TapDownDetails {
///
///
/// The position at which the pointer contacted the screen is available in the
/// The position at which the pointer contacted the screen is available in the
/// `details`.
/// `details`.
///
/// See also:
///
/// * [GestureDetector.onTapDown], which matches this signature.
/// * [TapGestureRecognizer], which uses this signature in one of its callbacks.
typedef
void
GestureTapDownCallback
(
TapDownDetails
details
);
typedef
void
GestureTapDownCallback
(
TapDownDetails
details
);
/// Details for [GestureTapUpCallback], such as position.
/// Details for [GestureTapUpCallback], such as position.
///
/// See also:
///
/// * [GestureDetector.onTapUp], which receives this information.
/// * [TapGestureRecognizer], which passes this information to one of its callbacks.
class
TapUpDetails
{
class
TapUpDetails
{
/// Creates details for a [GestureTapUpCallback].
/// Creates details for a [GestureTapUpCallback].
///
///
...
@@ -45,24 +60,53 @@ class TapUpDetails {
...
@@ -45,24 +60,53 @@ class TapUpDetails {
///
///
/// The position at which the pointer stopped contacting the screen is available
/// The position at which the pointer stopped contacting the screen is available
/// in the `details`.
/// in the `details`.
///
/// See also:
///
/// * [GestureDetector.onTapUp], which matches this signature.
/// * [TapGestureRecognizer], which uses this signature in one of its callbacks.
typedef
void
GestureTapUpCallback
(
TapUpDetails
details
);
typedef
void
GestureTapUpCallback
(
TapUpDetails
details
);
/// Signature for when a tap has occurred.
/// Signature for when a tap has occurred.
///
/// See also:
///
/// * [GestureDetector.onTap], which matches this signature.
/// * [TapGestureRecognizer], which uses this signature in one of its callbacks.
typedef
void
GestureTapCallback
(
);
typedef
void
GestureTapCallback
(
);
/// Signature for when the pointer that previously triggered a
/// Signature for when the pointer that previously triggered a
/// [GestureTapDownCallback] will not end up causing a tap.
/// [GestureTapDownCallback] will not end up causing a tap.
///
/// See also:
///
/// * [GestureDetector.onTapCancel], which matches this signature.
/// * [TapGestureRecognizer], which uses this signature in one of its callbacks.
typedef
void
GestureTapCancelCallback
(
);
typedef
void
GestureTapCancelCallback
(
);
/// Recognizes taps.
/// Recognizes taps.
///
///
/// Gesture recognizers take part in gesture arenas to enable potential gestures
/// to be disambiguated from each other. This process is managed by a
/// [GestureArenaManager] (q.v.).
///
/// [TapGestureRecognizer] considers all the pointers involved in the pointer
/// [TapGestureRecognizer] considers all the pointers involved in the pointer
/// event sequence as contributing to one gesture. For this reason, extra
/// event sequence as contributing to one gesture. For this reason, extra
/// pointer interactions during a tap sequence are not recognized as additional
/// pointer interactions during a tap sequence are not recognized as additional
/// taps. For example, down-1, down-2, up-1, up-2 produces only one tap on up-1.
/// taps. For example, down-1, down-2, up-1, up-2 produces only one tap on up-1.
///
///
/// The lifecycle of events for a tap gesture is as follows:
///
/// * [onTapDown], which triggers after a short timeout ([deadline]) even if the
/// gesture has not won its arena yet.
/// * [onTapUp] and [onTap], which trigger when the pointer is released if the
/// gesture wins the arena.
/// * [onTapCancel], which triggers instead of [onTapUp] and [onTap] in the case
/// of the gesture not winning the arena.
///
/// See also:
/// See also:
///
///
/// * [GestureDetector.onTap], which uses this recognizer.
/// * [MultiTapGestureRecognizer]
/// * [MultiTapGestureRecognizer]
class
TapGestureRecognizer
extends
PrimaryPointerGestureRecognizer
{
class
TapGestureRecognizer
extends
PrimaryPointerGestureRecognizer
{
/// Creates a tap gesture recognizer.
/// Creates a tap gesture recognizer.
...
@@ -70,17 +114,54 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer {
...
@@ -70,17 +114,54 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer {
/// A pointer that might cause a tap has contacted the screen at a particular
/// A pointer that might cause a tap has contacted the screen at a particular
/// location.
/// location.
///
/// This triggers before the gesture has won the arena, after a short timeout
/// ([deadline]).
///
/// If the gesture doesn't win the arena, [onTapCancel] is called next.
/// Otherwise, [onTapUp] is called next.
///
/// See also:
///
/// * [GestureDetector.onTapDown], which exposes this callback.
GestureTapDownCallback
onTapDown
;
GestureTapDownCallback
onTapDown
;
/// A pointer that will trigger a tap has stopped contacting the screen at a
/// A pointer that will trigger a tap has stopped contacting the screen at a
/// particular location.
/// particular location.
///
/// This triggers once the gesture has won the arena, immediately before
/// [onTap].
///
/// If the gesture doesn't win the arena, [onTapCancel] is called instead.
///
/// See also:
///
/// * [GestureDetector.onTapUp], which exposes this callback.
/// * [TapUpDetails], which is passed as an argument to this callback.
GestureTapUpCallback
onTapUp
;
GestureTapUpCallback
onTapUp
;
/// A tap has occurred.
/// A tap has occurred.
///
/// This triggers once the gesture has won the arena, immediately after
/// [onTapUp].
///
/// If the gesture doesn't win the arena, [onTapCancel] is called instead.
///
/// See also:
///
/// * [GestureDetector.onTap], which exposes this callback.
GestureTapCallback
onTap
;
GestureTapCallback
onTap
;
/// The pointer that previously triggered [onTapDown] will not end up causing
/// The pointer that previously triggered [onTapDown] will not end up causing
/// a tap.
/// a tap.
///
/// This triggers if the gesture loses the arena.
///
/// If the gesture wins the arena, [onTapUp] and [onTap] are called instead.
///
/// See also:
///
/// * [GestureDetector.onTapCancel], which exposes this callback.
GestureTapCancelCallback
onTapCancel
;
GestureTapCancelCallback
onTapCancel
;
bool
_sentTapDown
=
false
;
bool
_sentTapDown
=
false
;
...
...
packages/flutter/lib/src/widgets/gesture_detector.dart
View file @
3acc2785
...
@@ -203,17 +203,35 @@ class GestureDetector extends StatelessWidget {
...
@@ -203,17 +203,35 @@ class GestureDetector extends StatelessWidget {
/// A pointer that might cause a tap has contacted the screen at a particular
/// A pointer that might cause a tap has contacted the screen at a particular
/// location.
/// location.
///
/// This is called after a short timeout, even if the winning gesture has not
/// yet been selected. If the tap gesture wins, [onTapUp] will be called,
/// otherwise [onTapCancel] will be called.
final
GestureTapDownCallback
onTapDown
;
final
GestureTapDownCallback
onTapDown
;
/// A pointer that will trigger a tap has stopped contacting the screen at a
/// A pointer that will trigger a tap has stopped contacting the screen at a
/// particular location.
/// particular location.
///
/// This triggers immediately before [onTap] in the case of the tap gesture
/// winning. If the tap gesture did not win, [onTapCancel] is called instead.
final
GestureTapUpCallback
onTapUp
;
final
GestureTapUpCallback
onTapUp
;
/// A tap has occurred.
/// A tap has occurred.
///
/// This triggers when the tap gesture wins. If the tap gesture did not win,
/// [onTapCancel] is called instead.
///
/// See also:
///
/// * [onTapUp], which is called at the same time but includes details
/// regarding the pointer position.
final
GestureTapCallback
onTap
;
final
GestureTapCallback
onTap
;
/// The pointer that previously triggered [onTapDown] will not end up causing
/// The pointer that previously triggered [onTapDown] will not end up causing
/// a tap.
/// a tap.
///
/// This is called after [onTapDown], and instead of [onTapUp] and [onTap], if
/// the tap gesture did not win.
final
GestureTapCancelCallback
onTapCancel
;
final
GestureTapCancelCallback
onTapCancel
;
/// The user has tapped the screen at the same location twice in quick
/// The user has tapped the screen at the same location twice in quick
...
...
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