]> git.saurik.com Git - wxWidgets.git/commitdiff
Add EndDialog helper which calls EndModal with the given return code if the
authorDavid Elliott <dfe@tgwbd.org>
Mon, 26 Sep 2005 15:42:42 +0000 (15:42 +0000)
committerDavid Elliott <dfe@tgwbd.org>
Mon, 26 Sep 2005 15:42:42 +0000 (15:42 +0000)
dialog is modal, and Show(false) if the dialog is not modal.  This allows
the default handlers for OK and Cancel to function without assertions.
This code is copied more or less directly from src/msw/dialog.cpp.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35730 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/cocoa/dialog.h
src/cocoa/dialog.mm

index b4e0145e911d1ca548d5aaf1c0a2042c122d62ae..a9e793a22d9ead8cea67bcbfc6cb500bad5aca23 100644 (file)
@@ -102,6 +102,10 @@ protected:
     void OnOK(wxCommandEvent& event);
     void OnApply(wxCommandEvent& event);
     void OnCancel(wxCommandEvent& event);
+
+    // end either modal or modeless dialog
+    void EndDialog(int rc);
+
 };
 
 #endif // _WX_COCOA_DIALOG_H_
index e15c2937aa8eaaf96ba5c66f16fde91958dbeba7..d18483cc868d4b17b052ff37b756fde1f448a4bf 100644 (file)
@@ -175,6 +175,14 @@ void wxDialog::EndModal(int retCode)
     Show(false);
 }
 
+void wxDialog::EndDialog(int retCode)
+{
+    if(IsModal())
+        EndModal(retCode);
+    else
+        Show(false);
+}
+
 void wxDialog::OnCloseWindow(wxCloseEvent& event)
 {
     // We'll send a Cancel message by default,
@@ -216,7 +224,7 @@ void wxDialog::OnOK(wxCommandEvent& event)
 {
     if ( Validate() && TransferDataFromWindow() )
     {
-        EndModal(wxID_OK);
+        EndDialog(wxID_OK);
     }
 }
 
@@ -230,6 +238,6 @@ void wxDialog::OnApply(wxCommandEvent& event)
 void wxDialog::OnCancel(wxCommandEvent& event)
 {
     wxLogTrace(wxTRACE_COCOA,wxT("Cancelled!"));
-    EndModal(wxID_CANCEL);
+    EndDialog(wxID_CANCEL);
 }