PDA

View Full Version : Cell click events



rszeto
21 Apr 2008, 7:18 AM
Hi, I am using the Table class and would like to catch both the single click and double click events. But I running into a problem where I am getting a single click event even when I double clicked. Only when I have not registered a single click event does the double click event come up.

Listener l = new Listener() {
public void handleEvent(BaseEvent be) {
if (be.type == Events.CellClick) {
Window.alert("Cell clicked: ");
} else if (be.type == Events.CellDoubleClick) {
Window.alert("Cell DBL clicked: ");
}
}
};

table.addListener(Events.CellDoubleClick, l);
table.addListener(Events.CellClick, l);

Can anyone please tell me if there is something wrong in the way I have done it or it is a bug?

Thanks
Rick

kcaseye
21 Apr 2008, 7:28 AM
Switch the order in your else if statement. Like this:


Listener l = new Listener() {
public void handleEvent(BaseEvent be) {
if (be.type == Events.CellDoubleClick) {
Window.alert("Cell DBL clicked: ");
} else if (be.type == Events.CellClick) {
Window.alert("Cell clicked: ");
}
}
};

rszeto
21 Apr 2008, 7:58 AM
I have tried switching the order of the if statement, but it did not correct the problem. Any thoughts? Also what was the idea behind switching the order of the if statement? Just curious :)

kcaseye
21 Apr 2008, 8:08 AM
I was thinking that the first if statement was catching both the single and double click events, but now that I think about it, it doesn't make sense.

rszeto
22 Apr 2008, 8:01 AM
Does anyone have any ideas what the problem is? Or should I just file this as a bug?

Rick

darrellmeyer
22 Apr 2008, 9:34 AM
There is a bug when adding both CellClick and CellDoubleClick. I am looking into this and will let you know when I find a fix.

rszeto
22 Apr 2008, 9:41 AM
Thanks Darrel. Awaiting fix.

alex.d
22 Aug 2008, 3:40 AM
Dealing with the above mentioned problem - any fix avaliable?

darrellmeyer
23 Aug 2008, 7:31 AM
There is not a bug. The issue is using the JavaScript alert. Try this code instead:


Listener l = new Listener() {
public void handleEvent(BaseEvent be) {
if (be.type == Events.CellClick) {
Info.display("Cell clicked: ", "", new String[0]);
} else if (be.type == Events.CellDoubleClick) {
Info.display("Cell double clicked: ", "", new String[0]);
}
}
};

Single and double both fire on a double click.

alex.d
24 Aug 2008, 10:37 PM
[/code]Single and double both fire on a double click.
They do. But isn't this a bug too? I mean, i a double click, isn't a click and a double click at the same time, isn't it?