0

do you know if it is possible to close Vaadin addon MessageBox with keyPress? I didn't find anything about that in documentation. Only thing I found out is that I can confirm button with 'Enter' when it is focused, but I also want to close it with 'ESC' (bind 'ESC' to 'Close' button).

Code snippet:

 MessageBox mb = MessageBox.createInfo();
            mb.withMessage("Directory does not exist. Do you wish to create it?")
                .withYesButton(this::copyToNewDir,ButtonOption.focus()) // I can trigger this action with ENTER
            .withNoButton() //Don't know how to close this with ESC
            .open();

Thank you.

Pavol
  • 89
  • 1
  • 6
  • Asking the author via the normal channels will be more effective https://sourceforge.net/p/messagebox/discussion/?source=navbar – André Schild Apr 26 '18 at 06:14
  • I will try that, but at first I wanted to try luck on StackOverflow, because on discussion forum, last post was added/modified about year ago. Thank's for the tip anyway :) – Pavol Apr 26 '18 at 07:56

1 Answers1

0

By quick glance it looked like, there is getButton(..) method there in MessageBox, so if you can get the button which closes the window, you can set key shortcut you want with Button.setClickShortcut(..) method.

https://vaadin.com/download/release/8.4/8.4.0/docs/api/com/vaadin/ui/Button.html#setClickShortcut-int-int...-

Tatu Lund
  • 9,949
  • 1
  • 12
  • 26