CallOutBox and Command-Tab

A CalloutBox will not be automatically dismissed when the user uses command tab to switch to a different app. Is there some way to detect that the user used command tab to switch to a different app and safely close the CalloutBox?

You can check the current process with Process::isForegroundProcess

I see, but in response which event? I tried a Desktop::addFocusChangedListener, then closing using

[code]void RoutingPanel::globalFocusChanged (Component* focusedComponent)
{
if(!hasKeyboardFocus(true))
{
Component *c = findParentComponentOfClass();
if©
{
Desktop::getInstance().removeFocusChangeListener(this);

		c->inputAttemptWhenModal();
	}
}

}
[/code]

But this crashes.

I tried out a few things. Handling activeWindowStatusChanged on my main window like below consistently closes an open CallOutBox when switching away to a different app:

void MainAppWindow::activeWindowStatusChanged() { if(!isActiveWindow()) grabKeyboardFocus(); }