Suggestion on multiple component sharing KeyPressMappingSet

I need some suggestion cause i'm not able to make the code respond like i would. I explain the situation.

I have the application logic class, which holds the ApplicationCommandManager class and the state and functions that implements the program logic, then i have multiple windows that can be or not be open at the same time. Each window have sub components that are ApplicationCommandTarget that respond to specific actions and trigger main class logic (this way i can centralize ApplicationCommandManager::
to notify all the targets to update their state).

Each content component implement ApplicationCommandTarget::getNextCommandTarget like this:

ApplicationCommandTarget* ContentComponent::getNextCommandTarget()
    return findFirstTargetParentComponent();

So it should never reach the other window when the same command is invoked.

Now i want to register as key listeners for the two windows the same set of key mappings. For example, window 1 have ctrl+z mapped to undoAction, and window 2 have ctrl+z mapped to another action say saveAsAction.

Window 1 and Window 2 when they are opened do:

// ... constructor

// ... destructor
Array<CommandID> commands;
for (int i = 0; i < commands.size(); i++)

But if i open Window 1, then open and close Window 2, then Window 1 does not responds to key events anymore (and ctrl+z does nothing, and it's even removed from it's popup menu item description).

How i'm supposed to work in this situation ? Have a separate ApplicationCommandManager for every Target ? Create all the windows in advance and register everything without unregister the key listeners ?

Also how about responding to key events only for the window that actually have focus without routing events to the other window, which actually is a problem cause ApplicationCommandManager::setFirstCommandTarget should be the one with the focus ?

Anybody can shed some light on this ?


really ? anyone ?

how i'm supposed to register a keyboard listener for 2 windows which targets responds to the same keys with a single application command manager ?

to me, it seems the library implementation is a bit broken if it's impossible unless using multiple command managers for each own window...

I think the main reason for no replies here is probably a bit of a TL;DR problem.. Surely things like the Introjucer have multiple windows with a single key mapping and command manager?

yes but the fact is, when you close Introjucer main window, the application is closed. In my app, closing the main window doesn't exit the application and main window (or other windows) can be opened again.

yes but the fact is, when you close Introjucer main window, the application is closed

That's not true. When you close the last window in the Introjucer the app stays open so you can create a new project etc. (at least on OS X).

This probably works differently between platforms though. Surely on Windows you need something on the screen to keep the app alive? Even if it's just a floating toolbar with your shotcuts in it?

i think i made it work, i removed every call to setFirstCommandTarget like Introjucer is doing, then things started apparently working like i expect... will do more testing, at least my keyboard mapping sets are not unregistered from the whole windows !