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
[SelectionManager] Use event.detail instead for counting the mousedown event #780
Conversation
This is pretty cool, I'm a little concerned about browser support though as I don't trust w3schools and mdn says @rebornix you wouldn't happen to know why monaco doesn't use |
this._onDoubleClick(event); | ||
} else if (this._clickCount === 3) { | ||
} else if (event.detail === 3) { |
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.
Should this be >= to maintain current behavior?
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.
I think you are right, more than three clicks should yield the same behaviour as three clicks.
@Tyriar As far as I can tell, UIEvent.detail is well supported. I have tested it on Safari, Chrome, Firefox and IE10 a while back, all working. It is not very well documented, and I believe most people don't even know it exists. Actually, I have implemented a very similar solution to yours a few months ago, and then I've seen that cloud9 can handle the same thing, but with respecting the double click setting of the os, so I was wondering how they do it and found out that they were using evt.detail 😉 |
src/SelectionManager.ts
Outdated
@@ -385,7 +385,7 @@ export class SelectionManager extends EventEmitter { | |||
this._onSingleClick(event); | |||
} else if (event.detail === 2) { | |||
this._onDoubleClick(event); | |||
} else if (event.detail === 3) { | |||
} else if (event.detail >= 3) { |
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.
Actually looking closer at the code it was correct before 😅, we shouldn't need to re-perform triple click as we don't drop the selection between clicks 3 and 4.
Just revert that change and ready to go, pending the tests. I love deleting code 🎆 |
1 similar comment
Ready for take-off 🚀 |
@parisk is it possible to make the mac lint/test Travis jobs non-block to merge? There is quite a queue for Mac builds apparently. |
@Tyriar, yes of course. |
This PR introduces the usage of MouseEvent.detail to get the number of consecutive clicks.
See:
https://www.w3schools.com/jsref/event_detail.asp
This does not only reduce the complexity of the code base, but also respects the OS double click speed setting of the user.