]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/dialog.cpp
bug in wxSplitPath() corrected: the returned file name doesn't have the
[wxWidgets.git] / src / motif / dialog.cpp
index 16fc52abd55e805f8a6300d4c98534389c820d15..84712cd4e1cf962806ef53833d3f30da4547d5f7 100644 (file)
@@ -564,35 +564,34 @@ void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
     }
 }
 
-bool wxDialog::OnClose()
+void wxDialog::OnCloseWindow(wxCloseEvent& event)
 {
-    // Behaviour changed in 2.0: we'll send a Cancel message by default,
+    // We'll send a Cancel message by default,
     // which may close the dialog.
-    // Check for looping if the Cancel event handler calls Close()
-    
+    // Check for looping if the Cancel event handler calls Close().
+
+    // Note that if a cancel button and handler aren't present in the dialog,
+    // nothing will happen when you close the dialog via the window manager, or
+    // via Close().
+    // We wouldn't want to destroy the dialog by default, since the dialog may have been
+    // created on the stack.
+    // However, this does mean that calling dialog->Close() won't delete the dialog
+    // unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be
+    // sure to destroy the dialog.
+    // The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog.
+
     static wxList closing;
     
     if ( closing.Member(this) )
-        return FALSE;
+        return;
     
     closing.Append(this);
     
     wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
     cancelEvent.SetEventObject( this );
-    GetEventHandler()->ProcessEvent(cancelEvent);
-    
-    closing.DeleteObject(this);
-    
-    return FALSE;
-}
+    GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog
 
-void wxDialog::OnCloseWindow(wxCloseEvent& event)
-{
-    // Compatibility
-    if ( GetEventHandler()->OnClose() || event.GetForce())
-    {
-        this->Destroy();
-    }
+    closing.DeleteObject(this);
 }
 
 // Destroy the window (delayed, if a managed window)