Howto synthetisize double-clicks?

Clemens Eisserer linuxhippy at gmail.com
Fri Jun 3 10:01:57 PDT 2011


Hi,

I wonder how to synthetisize double-click mouse events, I played with
it for over a day, and I still can't seem to make it work.

For now I have the following (non-)proof-of-concept code, which
generates double-click events from pressed/release pairs.

	EventData data = new EventData();
	data.setSource(screen);
	data.setX(x);
	data.setY(y);
	data.setId(down ? MouseEvent.MOUSE_PRESSED : MouseEvent.MOUSE_RELEASED);
	data.setButton(jsButtonMaskToJava(buttonMask));
	data.setModifiers(jsButtonMaskToJavaMask(buttonMask));
	data.setTime(System.currentTimeMillis());

	if (lastClickedEvent != null && (System.currentTimeMillis() -
lastClickedEvent.getTime()) <= 200) {
	    data.setClickCount(2);
	} else {
	    data.setClickCount(1);
	}


So I actually generate a double-click event, if the last click happend
XYms after a first one, including the button-release events in
between.
Still in client-swing code, the double-click events are not "delivered".

Is there something I missed?
I ask because most likely I guess its some kind of "yeah, we thad to
figure it out too" question ;)

Thanks, Clemens

PS: Thanks Mario for answering my questions about the event pump. I
hope to continue work on that soon.



More information about the caciocavallo-dev mailing list