CallOutBox and Command-Tab


#1

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?


#2

You can check the current process with Process::isForegroundProcess


#3

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.


#4

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(); }