Double click

Hi All,

I have the necessity to prevent DoubleClicks. Is there a way to prevent this for Button? I found the addListener for DoubleClickListener is not implemented in the class Button.

Thank you very much,

Ivan

I found MouseEvents.DoubleClickListener and I need to listen double click at a Label. How can I do it?

Wrap the label in a layout, so you can add a LayoutClickListener.

VerticalLayout wrap = new VerticalLayout();
wrap.addComponent(your_label);

wrap.addListener(new LayoutClickListener()
        {
            
            @Override
            public void layoutClick(LayoutClickEvent event)
            {
                if (event.isDoubleClick()) {
                  //...
                }
            }
        });

Or change the Label into a Button and use the link style :
demo

Hacking around Label will be horrible performance wise…

In what way do you need to prevent the double clicks?

The regular Button component doesn’t react to it anyway, but if I assume correctly, you don’t want two sequential click events happening, only one. You could probably use the Button.setDisableOnClick(boolean) method to disallow two sequential clicks on the same button. Then just re-enable the button in the click listener on the server, so that the button is active again once the request comes back from the server.

Thanks a lot, it works fine.