I’ve a text field wich is a ClickNotifier.
When I double click on it the Click event is issuend 4 times.
2 times have clickCount = 1 and I can ignore them, but other 2 have clickCount = 2 and this is wrong because the listener is activated 2 times.
How can I avoid such effect ?
Tks
I cannot reproduce. This is the code I test with:
@Route
public class ClickView extends VerticalLayout {
private static class ClickField extends TextField implements ClickNotifier<ClickField> {
}
public ClickView() {
ClickField cf = new ClickField();
cf.addClickListener(event -> {
System.out.println(event.getClickCount());
});
add(cf);
}
}
When I double click the text field, it first prints 1 and then 2 as expected. I don’t get any duplicates.
Note that if you only care about double clicks, then you can also use addDoubleClickListener
which automatically filters out the events with the single click count already in the browser.