From f3e1f72f6dc8bd861345d2c1078bbf0cfb3a6987 Mon Sep 17 00:00:00 2001 From: Igor Korot Date: Fri, 24 May 2019 23:42:37 -0500 Subject: [PATCH] Test vetoing wxAuiNotebook page changing event in aui sample Make it simpler to check whether vetoing the page changing event works as it's supposed to. See #4518. Closes https://github.com/wxWidgets/wxWidgets/pull/1329 --- samples/aui/auidemo.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/samples/aui/auidemo.cpp b/samples/aui/auidemo.cpp index 38348d6331..348693cf14 100644 --- a/samples/aui/auidemo.cpp +++ b/samples/aui/auidemo.cpp @@ -153,6 +153,7 @@ private: void OnAllowNotebookDnD(wxAuiNotebookEvent& evt); void OnNotebookPageClose(wxAuiNotebookEvent& evt); void OnNotebookPageClosed(wxAuiNotebookEvent& evt); + void OnNotebookPageChanging(wxAuiNotebookEvent &evt); void OnExit(wxCommandEvent& evt); void OnAbout(wxCommandEvent& evt); void OnTabAlignment(wxCommandEvent &evt); @@ -654,6 +655,7 @@ wxBEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_AUINOTEBOOK_ALLOW_DND(wxID_ANY, MyFrame::OnAllowNotebookDnD) EVT_AUINOTEBOOK_PAGE_CLOSE(wxID_ANY, MyFrame::OnNotebookPageClose) EVT_AUINOTEBOOK_PAGE_CLOSED(wxID_ANY, MyFrame::OnNotebookPageClosed) + EVT_AUINOTEBOOK_PAGE_CHANGING(wxID_ANY, MyFrame::OnNotebookPageChanging) wxEND_EVENT_TABLE() @@ -1387,6 +1389,21 @@ void MyFrame::OnNotebookPageClosed(wxAuiNotebookEvent& evt) evt.Skip(); } +void MyFrame::OnNotebookPageChanging(wxAuiNotebookEvent& evt) +{ + if ( evt.GetOldSelection() == 3 ) + { + if ( wxMessageBox( "Are you sure you want to leave this page?\n" + "(This demonstrates veto-ing)", + "wxAUI", + wxICON_QUESTION | wxYES_NO, + this ) != wxYES ) + { + evt.Veto(); + } + } +} + void MyFrame::OnAllowNotebookDnD(wxAuiNotebookEvent& evt) { // for the purpose of this test application, explicitly