Detecting double click with MouseListener

J

John

Jacob said:
I can detect a docuble click using the MouseListener
interface and inspect the event.getClickCount().

However, at that point in time, the event has already
been classified as a single click (as the clickCount
is 1 the first time around).

My intention is to start action A on a single click
and action B on a double click. With a standard setup
I will get action A on a single click but action A + B
on a double click!

Seems like a delay is necessary in order to fully
classify the event. Is there a standard way to acheive
this?

Thanks.

Let's say the double click listener calls the method
handleDoubleClick(). In the single click listener, check the number of
clicks, and if it is 2, call handleDoubleClick().

Do NOT start buggering about with delays and things or your UI code will
degenerate into rubbish.

John
 
J

Jacob

I can detect a docuble click using the MouseListener
interface and inspect the event.getClickCount().

However, at that point in time, the event has already
been classified as a single click (as the clickCount
is 1 the first time around).

My intention is to start action A on a single click
and action B on a double click. With a standard setup
I will get action A on a single click but action A + B
on a double click!

Seems like a delay is necessary in order to fully
classify the event. Is there a standard way to acheive
this?

Thanks.
 
S

staff

John said:
Let's say the double click listener calls the method
handleDoubleClick(). In the single click listener, check the number of
clicks, and if it is 2, call handleDoubleClick().

This is not a solution. When double clicking two events are generated. First
with clickCount = 1, second with cilckCount = 2.

Greetings
Pawel Stawicki
 
N

Niels Dybdahl

Let's say the double click listener calls the method
handleDoubleClick(). In the single click listener, check the number of
clicks, and if it is 2, call handleDoubleClick().

Do NOT start buggering about with delays and things or your UI code will
degenerate into rubbish.

The Java versions I have worked with (Sun), there is only one
mouseclickevent, and in the case of a double click, that event is fired
twice, once with a clickcount of 1 and once with a clickcount of 2. At the
time when the clickcount of 1 is present, there is no way to determine
whether the user will click once more.

One possible method is to select a singleclickaction which does not conflict
with the doubleclickaction. F.ex single click->selection, double
click->activation.

I have had a few cases where I wanted actions that did conflict. I did not
implement the delay, but changed the actions.

Niels Dybdahl
 
J

John

staff said:
John wrote:




This is not a solution. When double clicking two events are generated. First
with clickCount = 1, second with cilckCount = 2.

Greetings
Pawel Stawicki

Ok, apologies. (and to OP).

John
 
J

Jacob

Jacob wrote:

I can detect a docuble click using the MouseListener
interface and inspect the event.getClickCount().

However, at that point in time, the event has already
been classified as a single click (as the clickCount
is 1 the first time around).

My intention is to start action A on a single click
and action B on a double click. With a standard setup
I will get action A on a single click but action A + B
on a double click!

Seems like a delay is necessary in order to fully
classify the event. Is there a standard way to acheive
this?


I'll try to fix this myself; In doing so I need access
to the system click interval. How?

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top