I have a tree panel and for each node i have single click and double click events. but when i double click it is firing the single click event also. so how to prevent firing single click event when double clicked?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Generally using both single click and double click events is considered a bad practice and highly discouraged.
However, if you still want to do this, the only way to be able to distinct between single click and double click is to artificially add this distintion by measuring time between clicks.
The idea is that you don’t do your single-click action right away but wait for a second click. If second click comes shortly, then your double click action gets triggered. Otherwise your single click action gets triggered after the delay.
Your code will look something like:
The obvious downsides are:
I don’t know any better solution, and again, I discourage you from using both single and double clicks at the same time, this usually leads to a broken user experience.