Double Click on button starts twice

Hello,
I’m using Vaadin 10 and I realized that when I double-click on a button, it starts the procedure twice. How can I prevent this behavior?
For now I’m solving using getClickCount on the event object and check that it is the first click but I have to do this on each button?

Thank you

There are fkidding me … there is not listener to doubleClick, but getClinkCount in event?

So in each lamdba I have to check, if user didn’t by mistake didn’t click “Create” twice? WTF.

agh, there is workaround

	/**
	 * Disables button after 1st click, then enables it after certain time => 2nd click is performed over disabled button
	 * => double-click is disabled
	 * @param btnSubmit
	 */
	private static void preventDoubleClick(Button btnSubmit) {
		UI ui = UI.getCurrent();
		btnSubmit.setDisableOnClick(true);
		btnSubmit.addClickListener(event -> setTimeoutAsync(() -> {
			ui.access(() -> btnSubmit.setEnabled(true));
		}, 300));
	}

	public static void setTimeoutAsync(Runnable runnable, int delay) {
		new Thread(() -> {
			try {
				Thread.sleep(delay);
				runnable.run();
			}
			catch (Exception e){
				log.error(e.getMessage(), e);
			}
		}).start();
	}

more correct fix (just instantly adds constructors ;))

public CustomButton extends Button {
	private ComponentEventListener<ClickEvent<Button>> doubleClickListener;
	private ComponentEventListener<ClickEvent<Button>> moreClickListener;

	@Override
	public Registration addClickListener(ComponentEventListener<ClickEvent<Button>> listener) {
		return super.addClickListener(event -> {
			if(event.getClickCount() == 1) {
				listener.onComponentEvent(event);
			} else if (event.getClickCount() == 2 && doubleClickListener != null) {
				doubleClickListener.onComponentEvent(event);
			} else if (event.getClickCount() > 2 && moreClickListener != null) {
				moreClickListener.onComponentEvent(event);
			}
		});
	}

	public GimsButton doubleClickListener(ComponentEventListener<ClickEvent<Button>> listener) {
		this.doubleClickListener = listener;
		return this;
	}

	public GimsButton moreClickListener(ComponentEventListener<ClickEvent<Button>> listener) {
		this.moreClickListener = listener;
		return this;
	}
}