Ticket #12187: wxWidgets-workswhenmodal.diff

File wxWidgets-workswhenmodal.diff, 1.4 KB (added by gmeeker, 11 years ago)
  • src/osx/cocoa/nonownedwnd.mm

     
    1414    #include "wx/nonownedwnd.h"
    1515    #include "wx/frame.h"
    1616    #include "wx/app.h"
     17    #include "wx/dialog.h"
    1718#endif
    1819
    1920#include "wx/osx/private.h"
     
    408409    }
    409410}
    410411
    411 void wxNonOwnedWindowCocoaImpl::Create( wxWindow* WXUNUSED(parent), const wxPoint& pos, const wxSize& size,
     412void wxNonOwnedWindowCocoaImpl::Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
    412413long style, long extraStyle, const wxString& WXUNUSED(name) )
    413414{
    414415    static wxNonOwnedWindowController* controller = NULL;
     
    516517        defer:NO
    517518        ];
    518519
     520    // If the parent is modal, wxFRAME_FLOAT_ON_PARENT
     521    // needs to be in kCGUtilityWindowLevel not kCGFloatingWindowLevel
     522    // to stay above the parent.
     523    // Cocoa's modal loop does not process other windows by default.
     524    wxDialog* parentDialog = wxDynamicCast(parent, wxDialog);
     525    if (parentDialog != NULL && parentDialog->IsModal() &&
     526        [m_macWindow isKindOfClass:[NSPanel class]])
     527    {
     528        if (level == kCGFloatingWindowLevel)
     529        {
     530            level = kCGUtilityWindowLevel;
     531        }
     532        [(NSPanel*)m_macWindow setWorksWhenModal:YES];
     533    }
     534
    519535    [m_macWindow setLevel:level];
    520536
    521537    [m_macWindow setDelegate:controller];