You know how some operating systems have a setting where you can
increase or decrease the double-click response rate, so for those who
don't double click so fast, it'll accept it with longer rest periods
between clicks? You need something like that. Because a double click
is nothing more than two single clicks, and it will be registered like
that in event handling.
Something simple like so:
Timer t = new Timer() { public void run() { } };;
public void onBrowserEvent(Event evt) {
switch(DOM.eventGetType(evt)) {
case Event.ONDBLCLICK:
t.cancel();
//Do something related to double click
break;
case Event.ONCLICK: {
t.cancel();
t = new Timer() {
public void run() {
//Do something related to single click
}
};
t.schedule(500); //num milliseconds before you decide double
click is out of the question
break;
}
default:
super.onBrowserEvent(evt);
}
}
***REAALLY* though, for most cases, you shouldn't implement both
single & double click on a single object, it's just bad taste. But if
you have to, that is *a* solution (not the single definitive one) that
should work.
--
Carl Scott
Software Developer, Solertium Corporation
> Thanks for replay.
> Unfortunately your solution is not correct.
> *
> sinkEvents(Event.ONCLICK);
> sinkEvents(Event.ONDBLCLICK);
> * is exactly the same as
> *sinkEvents(Event.ONCLICK | Event.ONDBLCLICK);*
>
> take a look at implementation of void
> com.google.gwt.user.client.ui.UIObject.sinkEvents(int eventBitsToAdd) :
>
> public void sinkEvents(int eventBitsToAdd) {
> DOM.sinkEvents(getElement(), eventBitsToAdd
> | DOM.getEventsSunk(getElement()));
> }
>
> So it works exactly the same.
> Any other ideas?
>
> Ewa
>
> 2008/5/1 Folke <
mess...@gmail.com>: