if the page changed due to pressing Ctrl-TAB was vetoed, the current tab was still changed (although the current page stayed the same!)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17798 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -133,10 +133,8 @@ protected:
|
|||||||
// remove one page from the notebook, without deleting
|
// remove one page from the notebook, without deleting
|
||||||
virtual wxNotebookPage *DoRemovePage(int nPage);
|
virtual wxNotebookPage *DoRemovePage(int nPage);
|
||||||
|
|
||||||
// helper functions
|
// the current selection (-1 if none)
|
||||||
void ChangePage(int nOldSel, int nSel); // change pages
|
int m_nSelection;
|
||||||
|
|
||||||
int m_nSelection; // the current selection (-1 if none)
|
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxNotebook)
|
DECLARE_DYNAMIC_CLASS(wxNotebook)
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
@@ -205,9 +205,23 @@ int wxNotebook::SetSelection(int nPage)
|
|||||||
{
|
{
|
||||||
wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
|
wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
|
||||||
|
|
||||||
ChangePage(m_nSelection, nPage);
|
if ( nPage != m_nSelection )
|
||||||
|
{
|
||||||
|
wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
|
||||||
|
event.SetSelection(nPage);
|
||||||
|
event.SetOldSelection(m_nSelection);
|
||||||
|
event.SetEventObject(this);
|
||||||
|
if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
|
||||||
|
{
|
||||||
|
// program allows the page change
|
||||||
|
event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
|
||||||
|
(void)GetEventHandler()->ProcessEvent(event);
|
||||||
|
|
||||||
return TabCtrl_SetCurSel(m_hwnd, nPage);
|
TabCtrl_SetCurSel(m_hwnd, nPage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_nSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxNotebook::SetPageText(int nPage, const wxString& strText)
|
bool wxNotebook::SetPageText(int nPage, const wxString& strText)
|
||||||
@@ -631,44 +645,4 @@ bool wxNotebook::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result)
|
|||||||
return processed;
|
return processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// wxNotebook helper functions
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// generate the page changing and changed events, hide the currently active
|
|
||||||
// panel and show the new one
|
|
||||||
void wxNotebook::ChangePage(int nOldSel, int nSel)
|
|
||||||
{
|
|
||||||
// MT-FIXME should use a real semaphore
|
|
||||||
static bool s_bInsideChangePage = FALSE;
|
|
||||||
|
|
||||||
// when we call ProcessEvent(), our own OnSelChange() is called which calls
|
|
||||||
// this function - break the infinite loop
|
|
||||||
if ( s_bInsideChangePage )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// it's not an error (the message may be generated by the tab control itself)
|
|
||||||
// and it may happen - just do nothing
|
|
||||||
if ( nSel == nOldSel )
|
|
||||||
return;
|
|
||||||
|
|
||||||
s_bInsideChangePage = TRUE;
|
|
||||||
|
|
||||||
wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
|
|
||||||
event.SetSelection(nSel);
|
|
||||||
event.SetOldSelection(nOldSel);
|
|
||||||
event.SetEventObject(this);
|
|
||||||
if ( GetEventHandler()->ProcessEvent(event) && !event.IsAllowed() )
|
|
||||||
{
|
|
||||||
// program doesn't allow the page change
|
|
||||||
s_bInsideChangePage = FALSE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
|
|
||||||
GetEventHandler()->ProcessEvent(event);
|
|
||||||
|
|
||||||
s_bInsideChangePage = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // wxUSE_NOTEBOOK
|
#endif // wxUSE_NOTEBOOK
|
||||||
|
Reference in New Issue
Block a user