setCloseShortcut not working as expected

I have a modal window in which I set the close shortcut to be the Escape key. The problem is that clicking the Escape key after the window is displayed does nothing. However, the window does contain a table, and if I select a row in the table, THEN click the Escape key, the window does close. I am using 7.1.7.

Does anyone have any idea why Escape does not work until a row is selected?

Here is my code:

[font=courier new]
public class TestEscape extends Window {
private final Table permissionTable = new Table();

public TestEscape() {
    setCloseShortcut( ShortcutAction.KeyCode.ESCAPE, null );
    setHeight( 400, Unit.PIXELS );
    setWidth( 1200, Unit.PIXELS );
    setContent( permissionTable );
    setModal( true );
    setResizable( false );
    permissionTable.setSelectable( true );
    permissionTable.addContainerProperty( "test", String.class, null );
    permissionTable.setVisibleColumns( new Object {"test"} );
    permissionTable.setColumnHeaders( "test" );

    Object id = permissionTable.addItem();
    Item item = permissionTable.getItem( id );
    item.getItemProperty( "test" ).setValue( "row 1" );


Hi Ron,

That’s because an opened subwindow does not have the focus by default. Set the focus in your code after you have added the window to UI by calling focus() method of Window. Then it should work as expected.

Here’s a example

TestEscape window = new TestEscape();


Thank you so much–that worked!