Out of Sync because of ClickShortCuts after the main window changes

In my application i have to switch between 2 main windows. Each of these windows contains a Clickshortcut for a button. Before replacing the main window all shortcuts work properly. When I replace a Main window by an other window with also some shortcuts and I am hitting the right shortcut key, I get out of sync. I ve reduced the problem to a simple application and able to reproduce the bug. Here is the code:

public class HelloApplication extends Application {
	private static final long serialVersionUID = -3367403263136031291L;
	private static int counter = 0;

	public void init() {
		Window mainWindow = new Window("Main Window "  + counter);
		Label label = new Label("Main Window " + counter++);
		Button button = getBuggedButton();
	public Button getBuggedButton() {
		Button button1 = new Button("Switch Main Window", new ClickListener() {
			public void buttonClick(ClickEvent event) {
				Window mainWindow2 = new Window("Main Window " + counter);
				Label label = new Label("Main Window " + counter++);
		button1.setClickShortcut(KeyCode.ENTER, null);
		return button1;


In these example you need to hit 2x Enter and the application gets at least in my browsers (FF 9.0.1 and Chrome 16.0.912.77 m) out of sync.
Am I doing something wrong by replacing the main window? If I reload the window by using window.open(url) after replacing the main window, then no out of sync gets produced. Has it something to do with the parent nodes of the main window element which not get refreshed after the main window change?

kind regards


I seem to recall that it is better to keep the same window and change the content:


instead of switching main windows all the time.

And I think changing the main window like this does not work at all when handling multi tab applications.


Thank you. I have refactored my application so that it uses only one main window and multiple main layouts as you said and it solved the problem.
The only deficit which I have now is that I need to remove all Clickshortcuts from all tabs inside a tabsheet which are not selected. If I not do so, the components inside the not selected tabs will still receive shortcut events.
It has nothing to do with the issue that i ve described above, I have already got a workaround with SelectedTabChangeListener, but in my eyes its a deficit. I would expect that the tabs get their own shortcut scope which is separated from other tabs.

Sorry for bad english and thank you very much for your tip. Now I do not have to reload the whole application when I switch main content :slight_smile:

kind regards


If I remember correctly, shortcut scopes are currently only limited by Window and Panel, but I agree a TabSheet or an Accordion should also limit the scope to the visible tab. Please
create a ticket
about this.