using setDisableOnClick(true) and setClickShortcut()

Hi there,

We have a button where we enabled the setDisableOnClick(true) and setClickShortcut(KeyCode.ENTER). According to the doc setDisableOnClick(true) is only used when the click comes from the user, not when calling click(). Not sure if this is related to the behavior we are noticing. But the fact is than we press the shortcut key assigned with setClickShortcut() the button is not being disabled.

Is this the way it is designed to work? We are on version 7.3.2

Many thanks,
Luis

Check this:

        VerticalLayout layout = new VerticalLayout();

        Button btn = new Button("Click Me");
        btn.setDisableOnClick(true);
        btn.setClickShortcut(KeyCode.DELETE);
        btn.addClickListener(new ClickListener() {
            
            @Override
            public void buttonClick(ClickEvent event) {
                System.out.println("clicked");
            }
        });
        layout.addComponent(btn);
        setContent(layout);

        btn.focus();

By default, the enter key is a click shortcut when focused. In the last line I’ve set the focus on the button, then just press the enter key it is disabled confomre your event. But set a shortcut click, which is the DELETE key, pressing it calls the listener, but not disabled, which seem to only work when the event is fired directly on the button and not the shortcut. Maybe you found a bug (:

Hola Gabriel,

Thanks for the comment. If you set the “ClickShortcut” you don’t even need to set the focus on the button to mimmic the click when you press the associated key, that’s the advantage.

It might be a bug, but before opening a ticket just want to make sure if this is the way it should work. That said, it wouldn’t make much sense.

Many thanks,
Luis

Hi!
I have a similiar problem with setClickShortcut. I’m working with Vaadin 7.3.5.

This is my code:
c_btnBack.setClickShortcut(KeyCode.BACKSPACE);
c_btnBack.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            System.out.println("back");
        }
    });

This doesn’t work me, any suggestion?

Thanks a lot for advanced!
David

I agree this seems a bug :frowning:

I’ve checked the code and internally Vaadin uses click() when the shortcut is pressed. Therefore no disabling. If you think this should be changed, file a ticket and we’ll discuss it.

This code works for me in Chrome and FF on Mac. In which browser are you testing it?

Hi Michael, please see http://dev.vaadin.com/ticket/15386

Thanks Luis, I’ll take a look.