-
Notifications
You must be signed in to change notification settings - Fork 26.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Proposal] Modify 300ms delay when using double tap #106170
Comments
Hi @toly1994328, Thanks for filing the issue. This is currently not possible to configure the double-tap duration. I will leave this for the team to decide.
|
Are you trying to use a double tap gesture recognizer to simulate a double click recognizer? |
Hi Flutter team, Any updates on this issue? |
As a workaround you can wrap a Listener(
onPointerDown: (event) => handleTap(),
child: GestureDetector(
onDoubleTap: handleDoubleTap,
child: ...)); Use with a caution; comes with the side-effects where both a double tap and two taps are registered, but at least there is no delay :) |
@kozw I don't understand why this issue and various workarounds still exist. |
I'm with you, should be an easy fix |
I leave a workaround in case it helps someone: You can extend from
You could use this |
Also, besides allowing programmers to customize this value, it should be decreased for Desktop platforms by default, because it leads to a very poor user experience. |
@juanmasilf Could you provide an example of how to use it in |
I believe this shall be solved on a Flutter level, in my case this code works: int lastTap = DateTime.now().millisecondsSinceEpoch;
int consecutiveTaps = 1;
return GestureDetector(
onTap: () {
int now = DateTime.now().millisecondsSinceEpoch;
if (now - lastTap < 300) {
consecutiveTaps++;
if (consecutiveTaps >= 2) {
onDoubleTapFn();
}
} else {
consecutiveTaps = 1;
onTapFn();
}
lastTap = now;
},
child: widget
); Bear in mind that |
Fantastic idea, I love it. I had a lot of issues with nested GestureDetectors. Usually, its one parent widget with onDoubleTap, for example, a MessageBubble container. Now I'm finally able to have both events: onTap for links and onDoubleTap for parent widget, without any delay. Thanks! |
Hey, any progress on this in the last two years? As for @tomekit solution it is unfortunately wrong - without a timer you can't separate a single tap from a double, each time you do a double it'll also execute the one tap. A working solution:
|
@margorczynski your solution is the same as GestureDetector with onTap and onDoubleTap |
@vizakenjack well you simply modify the Duration value to modify the time window between two single taps and a double tap. The gesture detector doesn't offer that from what I understand as it is hardcoded to 300ms - this is the topic of this issue. |
@margorczynski actually there is another issue. For example, you have a Message widget with onDoubleTap to reply. And you have a Link widget as child in Message, with onTap. And when you tap on that child link, there will be an extra delay because of parent widget. |
@margorczynski and @vizakenjack and others, here is an implementation to separate tap counts, and also configure delay. This should support N taps, and would only call its respective callback:
To use this, it would look something like this:
|
When I use DoubleTap and Tap together ,tap will delay 300ms to check it's DoubleTap or not . It doesn't matter on mobile,but in desktop , there is a significant delay when tap fast . I know the reason is kDoubleTapTimeout ms Timer,but it's const. May I have access to change it , or have any solution to handle click speed ?
flutter --version
Flutter 3.0.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision fb57da5 (4 weeks ago) • 2022-05-19 15:50:29 -0700
Engine • revision caaafc5604
Tools • Dart 2.17.1 • DevTools 2.12.2
The text was updated successfully, but these errors were encountered: