Double-click in Table generates three ItemClickEvents

I have a Table that implements ItemClickEvent.ItemClickListener. It only used to look for event.isDoubleClick() in the Listener and this worked fine.

Now I want it to do something different when there’s a single-click. Single-click works fine. However, when I double-click on the table, three ItemClickEvents are generated, two of which are single-click and the third is a double-click.

How can I determine if a single-click is part of a double-click event? Having the Listener outside the Table doesn’t make any difference.

If there’s no easy way to tell them apart, this is likely a bug.

The problem with the first single click is probably unavoidable. For the sake of responsiveness, you want the single-click event to be sent immediately on mouse-release, but it’s impossible to know if there’s another click coming.

For the second click, the behavior that there’s both a single-click event and a double-click event sent seems like a bug. It seems to be a browser-dependent issue in GWT,
as described here
. It’s a five years old post, and the issue
is apparently still there
.

This GWT issue could perhaps be solved in Vaadin a bit faster, so please file a ticket. The second click also shouldn’t cause two separate server requests as it does now.

I don’t what your application is like, but perhaps you could design your UI logic so that it doesn’t mind about the problem. The current behavior should work OK in cases where a single click selects something and double click opens details, for example. Double-selecting the same item should not be a problem if you have set setNullSelectionAllowed(false). Deselecting by single-click would probably not be possible though.

I created a ticket (#6726).

Turns out, you can avoid the first click because it has a source (event.getSource()) of null and you generally don’t want to do anything for a click that wasn’t on a field.

The problem is the next two clicks. You cannot know if the double-click event is coming after the second single-click event. A null source single-click event following a non-null source single-click event doesn’t necessarily mean it’s a double click, because null source single-click events can legitimately be generated if the user clicks outside a field.

I have the following suboptimal workaround described in the ticket:

“My application sometimes brings up another window depending on what field in the table you click on. If you double click on that field, it does bring up the field, but will bring it down if there is an immediately following double-click event on the same field. However, the user clearly sees a window coming up and down. It is by no means invisible.”