Add EndDialog helper which calls EndModal with the given return code if the

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
This commit is contained in:
David Elliott
2005-09-26 15:42:42 +00:00
parent 38d4b1e4bc
commit acb96ac277
2 changed files with 14 additions and 2 deletions

View 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_

View 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);
}