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.
This commit is contained in:
committed by
Vadim Zeitlin
parent
f68c88b8d2
commit
b9b9a30bc7
@@ -99,7 +99,6 @@ public:
|
|||||||
// callbacks
|
// callbacks
|
||||||
// ---------
|
// ---------
|
||||||
void OnSize(wxSizeEvent& event);
|
void OnSize(wxSizeEvent& event);
|
||||||
void OnSelChange(wxBookCtrlEvent& event);
|
|
||||||
void OnSetFocus(wxFocusEvent& event);
|
void OnSetFocus(wxFocusEvent& event);
|
||||||
void OnNavigationKey(wxNavigationKeyEvent& event);
|
void OnNavigationKey(wxNavigationKeyEvent& event);
|
||||||
|
|
||||||
|
@@ -30,8 +30,6 @@
|
|||||||
#define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount())
|
#define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount())
|
||||||
|
|
||||||
wxBEGIN_EVENT_TABLE(wxNotebook, wxBookCtrlBase)
|
wxBEGIN_EVENT_TABLE(wxNotebook, wxBookCtrlBase)
|
||||||
EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, wxNotebook::OnSelChange)
|
|
||||||
|
|
||||||
EVT_SIZE(wxNotebook::OnSize)
|
EVT_SIZE(wxNotebook::OnSize)
|
||||||
EVT_SET_FOCUS(wxNotebook::OnSetFocus)
|
EVT_SET_FOCUS(wxNotebook::OnSetFocus)
|
||||||
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
|
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
|
||||||
@@ -313,16 +311,6 @@ void wxNotebook::OnSize(wxSizeEvent& event)
|
|||||||
event.Skip();
|
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)
|
void wxNotebook::OnSetFocus(wxFocusEvent& event)
|
||||||
{
|
{
|
||||||
// set focus to the currently selected page if any
|
// set focus to the currently selected page if any
|
||||||
@@ -465,21 +453,13 @@ bool wxNotebook::OSXHandleClicked( double WXUNUSED(timestampsec) )
|
|||||||
SInt32 newSel = GetPeer()->GetValue() - 1 ;
|
SInt32 newSel = GetPeer()->GetValue() - 1 ;
|
||||||
if ( newSel != m_selection )
|
if ( newSel != m_selection )
|
||||||
{
|
{
|
||||||
wxBookCtrlEvent changing(
|
if ( SendPageChangingEvent(newSel) )
|
||||||
wxEVT_NOTEBOOK_PAGE_CHANGING, m_windowId,
|
|
||||||
newSel , m_selection );
|
|
||||||
changing.SetEventObject( this );
|
|
||||||
HandleWindowEvent( changing );
|
|
||||||
|
|
||||||
if ( changing.IsAllowed() )
|
|
||||||
{
|
{
|
||||||
wxBookCtrlEvent event(
|
// m_selection is set to newSel in ChangePage()
|
||||||
wxEVT_NOTEBOOK_PAGE_CHANGED, m_windowId,
|
// so store its value for event use.
|
||||||
newSel, m_selection );
|
int oldSel = m_selection;
|
||||||
event.SetEventObject( this );
|
ChangePage(oldSel, newSel);
|
||||||
HandleWindowEvent( event );
|
SendPageChangedEvent(oldSel, newSel);
|
||||||
|
|
||||||
m_selection = newSel;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user