Table, Shortcut and Focus Listener


I have guestion about component Table and Shortcut and Focus Listener.

Can be ShortcutListener on the table active only if table has focus?

I have form with many others components and e.g. in RichTextArea don’t work key Enter because ShortcutListener on table.

I need something like this:

ShortcutListener myShortcutListener = new ShortcutListener("", KeyCode.ENTER, null) {
    public void handleAction(Object sender, Object target) {

myTable.addListener(new FocusListener() {
    public void focusGained(FocusEvent e) {

    public void focusLost(FocusEvent e) {

I know I’m a bit late to answer, but have you tried a combination of FocusListener for gained focus and BlurListener for lost focus? I’ve used those for adding/removing clickShortcuts from textfield-specific buttons at least.

Hello Anna,

but (according to me) component table doesn’t support FocusListener and BlurListener like component Textfield eg.

Ah, sorry, my bad. You are right, Table doesn’t have those listeners, and since it’s Table it probably won’t be trivial to add those features either. And it looks like RichTextArea doesn’t have them either, so you can’t tie it to that either. Tricky situation. Can’t think of any general solutions off the top of my head, sorry :frowning:

I don’t know if i’m thinking too simple here but can’t you just pack the two components into different panels and then add your shortcutlistener to the panel? This way when the panel and all the components inside it loose focus the shortcutlistener should not be active anymore.

Sampler example

Great idea. It works, thanks.