From b9b9a30bc72172dc89a00898fe76b39fca7987cd Mon Sep 17 00:00:00 2001 From: John Roberts Date: Tue, 13 Oct 2015 14:31:14 +0200 Subject: [PATCH] Don't rely on getting PAGE_CHANGED event in wxOSX wxNotebook The user code may handle this event, meaning that its handler in wxNotebook itself is never invoked, but this broke actually changing the pages. Fix this by doing the page change in the code handling the underlying OS X event directly. Closes #17197. --- include/wx/osx/notebook.h | 1 - src/osx/notebook_osx.cpp | 32 ++++++-------------------------- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/include/wx/osx/notebook.h b/include/wx/osx/notebook.h index 8f14236ae2..e0e91b8e33 100644 --- a/include/wx/osx/notebook.h +++ b/include/wx/osx/notebook.h @@ -99,7 +99,6 @@ public: // callbacks // --------- void OnSize(wxSizeEvent& event); - void OnSelChange(wxBookCtrlEvent& event); void OnSetFocus(wxFocusEvent& event); void OnNavigationKey(wxNavigationKeyEvent& event); diff --git a/src/osx/notebook_osx.cpp b/src/osx/notebook_osx.cpp index e463af641c..2b1330cd9c 100644 --- a/src/osx/notebook_osx.cpp +++ b/src/osx/notebook_osx.cpp @@ -30,8 +30,6 @@ #define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount()) wxBEGIN_EVENT_TABLE(wxNotebook, wxBookCtrlBase) - EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, wxNotebook::OnSelChange) - EVT_SIZE(wxNotebook::OnSize) EVT_SET_FOCUS(wxNotebook::OnSetFocus) EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey) @@ -313,16 +311,6 @@ void wxNotebook::OnSize(wxSizeEvent& event) event.Skip(); } -void wxNotebook::OnSelChange(wxBookCtrlEvent& event) -{ - // is it our tab control? - if ( event.GetEventObject() == this ) - ChangePage(event.GetOldSelection(), event.GetSelection()); - - // we want to give others a chance to process this message as well - event.Skip(); -} - void wxNotebook::OnSetFocus(wxFocusEvent& event) { // set focus to the currently selected page if any @@ -465,21 +453,13 @@ bool wxNotebook::OSXHandleClicked( double WXUNUSED(timestampsec) ) SInt32 newSel = GetPeer()->GetValue() - 1 ; if ( newSel != m_selection ) { - wxBookCtrlEvent changing( - wxEVT_NOTEBOOK_PAGE_CHANGING, m_windowId, - newSel , m_selection ); - changing.SetEventObject( this ); - HandleWindowEvent( changing ); - - if ( changing.IsAllowed() ) + if ( SendPageChangingEvent(newSel) ) { - wxBookCtrlEvent event( - wxEVT_NOTEBOOK_PAGE_CHANGED, m_windowId, - newSel, m_selection ); - event.SetEventObject( this ); - HandleWindowEvent( event ); - - m_selection = newSel; + // m_selection is set to newSel in ChangePage() + // so store its value for event use. + int oldSel = m_selection; + ChangePage(oldSel, newSel); + SendPageChangedEvent(oldSel, newSel); } else {