-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Fix DoubleTapped on touch #7213
Conversation
src/Avalonia.Input/Gestures.cs
Outdated
@@ -6,6 +6,7 @@ namespace Avalonia.Input | |||
{ | |||
public static class Gestures | |||
{ | |||
private static bool _isDoubleTapped = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a global variable. We usually try to avoid those
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Device and input state information must usually be maintained and managed centrally. It might help to suggest an alternative. Otherwise, I expect to see things like this myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The app might run on 2 independent touch screens. Or even on 1 touch screen with 2 windows on it. Because of such global variables we'll misinterpret tap sequences caused by the user tapping on those windows sequentially.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided to temporarily leave it as is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing is more permanent than temporary :) I would comment in the code that it should change in the future and why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing is more permanent than temporary
Yes, the original static variable in that file dates back to 2016 when DoubleTapped event was introduced. So we aren't introducing any new problems.
I'm getting an intermittent test failure in All service registrations for unit tests need to be done inside the |
Before this PR DoubleTapped event cant be triggered by touch input. Now it should work correctly.
Other frameworks like WPF\WinForms doesn't seem to count more than 3\4 clicks but I think there could be some use-cases for that so our implementation just basically counts clicks without any limitations. I don't have any devices with Touch so I can't test it, please test it by yourself. If more tests are needed I can add some. Click counting logic is copy-pasted(mostly) from MouseDevice but I don't think I can refactor it or improve in any way.
Also fixes DoubleTapped to be raised even if you click 4,6,8..etc times in a row, it matches UWP behaviour.
Also fixes Tapped. Now it wouldn't be raised twice when you click twice, Tapped would be raised once and DoubleTapped once,matches UWP behaviour.
Note:
On this line I hardcoded those values because we don't have separate settings for touch and it is really hard to hit into the size of the square declared for the mouse with touch. It is temporal change.
Checklist
Obsoletions / Deprecations
ClickCount is not Obsolete anymore.
Fixed issues
Closes #5412
Closes #6949