Supporting deeper nesting levels of modal dialogs on macOS

In order to make sure a parent NSPanel cannot be activated, turn off its worksWhenModal flag while the child has its turn

see #18204
This commit is contained in:
Stefan Csomor
2018-08-26 16:52:40 +02:00
parent f38b4d8ae3
commit cfab2206da

View File

@@ -435,9 +435,26 @@ void wxModalEventLoop::OSXDoRun()
#if OSX_USE_MODAL_SESSION
if ( m_modalWindow )
{
bool restoreWorksWhenModal = false;
wxDialog* const parentDialog = wxDynamicCast(wxGetTopLevelParent(m_modalWindow->GetParent()), wxDialog);
NSWindow* parentWindow = parentDialog && parentDialog->IsModal() ? parentDialog->GetWXWindow() : nil;
if ( parentWindow != nil )
{
if ( [parentWindow isKindOfClass:[NSPanel class]] && [(NSPanel*)parentWindow worksWhenModal] == YES )
{
[(NSPanel*)parentWindow setWorksWhenModal:NO];
restoreWorksWhenModal = true;
}
}
BeginModalSession(m_modalWindow);
wxCFEventLoop::OSXDoRun();
EndModalSession();
if ( restoreWorksWhenModal )
{
[(NSPanel*)parentWindow setWorksWhenModal:YES];
}
}
else
#endif