X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4d572a2cace8d11a10ecea598ff342c36ec007cf..6178debcd342963974dbdce6ac2ddb2fbe89e42a:/src/osx/dialog_osx.cpp?ds=sidebyside diff --git a/src/osx/dialog_osx.cpp b/src/osx/dialog_osx.cpp index 02bde473d3..b1b50b980a 100644 --- a/src/osx/dialog_osx.cpp +++ b/src/osx/dialog_osx.cpp @@ -12,6 +12,7 @@ #include "wx/wxprec.h" #include "wx/dialog.h" +#include "wx/evtloop.h" #ifndef WX_PRECOMP #include "wx/app.h" @@ -22,17 +23,30 @@ #include "wx/osx/private.h" +static int s_openDialogs = 0; +bool wxDialog::OSXHasModalDialogsOpen() +{ + return s_openDialogs > 0; +} -// Lists to keep track of windows, so we can disable/enable them -// for modal dialogs +void wxDialog::OSXBeginModalDialog() +{ + s_openDialogs++; +} + +void wxDialog::OSXEndModalDialog() +{ + wxASSERT_MSG( s_openDialogs > 0, "incorrect internal modal dialog count"); + s_openDialogs--; +} -wxList wxModalDialogs; IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow) void wxDialog::Init() { m_modality = wxDIALOG_MODALITY_NONE; + m_eventLoop = NULL; } bool wxDialog::Create( wxWindow *parent, @@ -122,12 +136,19 @@ bool wxDialog::Show(bool show) // Replacement for Show(true) for modal dialogs - returns return code int wxDialog::ShowModal() { - m_modality = wxDIALOG_MODALITY_WINDOW_MODAL; + m_modality = wxDIALOG_MODALITY_APP_MODAL; Show(); - DoShowModal(); - + wxModalEventLoop modalLoop(this); + m_eventLoop = &modalLoop; + + wxDialog::OSXBeginModalDialog(); + modalLoop.Run(); + wxDialog::OSXEndModalDialog(); + + m_eventLoop = NULL; + return GetReturnCode(); } @@ -149,6 +170,9 @@ wxDialogModality wxDialog::GetModality() const // dialogs and should work for both of them void wxDialog::EndModal(int retCode) { + if ( m_eventLoop ) + m_eventLoop->Exit(retCode); + SetReturnCode(retCode); Show(false); }