How do I add a 2x click listener on a vaadin grid? When I 2x click on it, it takes me to another page. Example would be most appreciated.
Asked
Active
Viewed 4,868 times
2 Answers
3
With the MouseEvent you can simply ask for a double click.

Murat Karagöz
- 35,401
- 16
- 78
- 107
-
It only detects double-click if `setEditorEnabled(false)`. If it's true, the double-click event edits by default. – Bruno Medeiros Aug 24 '16 at 19:34
-
2
Here is an example:
grid.addItemClickListener(listener ->
{
if (listener.getMouseEventDetails().isDoubleClick())
// pass the row/item that the user double clicked
// to method doStuff.
doStuff(l.getItem());
}
);

Brett Sutton
- 3,900
- 2
- 28
- 53
-
Hi @Brett, i'm using Vaadin 7 and trying to get Double click event for the grid, but i couldn't have getMouseEventDetails() method. Instead i have the isDoubleClick() method, like below, grid.addItemClickListener(e -> { if(e.isDoubleClick()) { System.out.println("Double click"); } else { System.out.println("Single click"); } }); But, when i do double click, it's fall under single click only. How to overcome this issue. – Pearl Apr 29 '19 at 11:41
-
@Pearl please have a look at the comment below the accepted answer. I think the described scenario is the same that you have. if you `setEditorEnabled(false)` then `e.isDoubleClick()` returns true. – codinghaus Apr 29 '19 at 12:23
-
@codinghaus, if there is any way to differentiate single click and double click if we set the setEditorEnabled(true). – Pearl Apr 29 '19 at 12:31