]> git.saurik.com Git - wxWidgets.git/commitdiff
Change wxNotebook selection before sending page changed event in wxMSW.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 23 Apr 2011 16:19:15 +0000 (16:19 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 23 Apr 2011 16:19:15 +0000 (16:19 +0000)
wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED handler should see the new page selected
in the control, not the old one as was the case if the page was changed using
the mouse in wxMSW.

This should have been done together with the other changes of r66224, see its
commit message for more details.

Closes 13145.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67589 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/notebook/notebook.cpp
src/msw/notebook.cpp

index 7e1a3e025ba554425b004ccbfdd3518f5711bcb0..3aceabbe2fc94d2af6a3e79edbc3f5601174838e 100644 (file)
@@ -972,6 +972,12 @@ void MyFrame::OnBookCtrl(wxBookCtrlBaseEvent& event)
              nameControl,
              veto;
     const wxEventType eventType = event.GetEventType();
+
+    // NB: can't use wxStaticCast here as wxBookCtrlBase is not in
+    //     wxRTTI
+    const wxBookCtrlBase * const
+        book = static_cast<wxBookCtrlBase *>(event.GetEventObject());
+
     for ( size_t n = 0; n < WXSIZEOF(events); n++ )
     {
         const EventInfo& ei = events[n];
@@ -983,10 +989,6 @@ void MyFrame::OnBookCtrl(wxBookCtrlBaseEvent& event)
         {
             const int idx = event.GetOldSelection();
 
-            // NB: can't use wxStaticCast here as wxBookCtrlBase is not in
-            //     wxRTTI
-            const wxBookCtrlBase * const
-                book = static_cast<wxBookCtrlBase *>(event.GetEventObject());
             if ( idx != wxNOT_FOUND &&
                     book && book->GetPageText(idx) == VETO_PAGE_NAME )
             {
@@ -1017,13 +1019,14 @@ void MyFrame::OnBookCtrl(wxBookCtrlBaseEvent& event)
 
     static int s_num = 0;
 
-    wxLogMessage(wxT("Event #%d: %s: %s (%d) new sel %d, old %d%s"),
+    wxLogMessage(wxT("Event #%d: %s: %s (%d) new sel %d, old %d, current %d%s"),
                  ++s_num,
                  nameControl.c_str(),
                  nameEvent.c_str(),
                  eventType,
                  event.GetSelection(),
                  event.GetOldSelection(),
+                 book->GetSelection(),
                  veto.c_str());
 
 #if USE_LOG
index db3df7f5387404d1f4b0493b5d40716ad57d0f42..1879bb2ba3df3c3f59009e00ce8eb1aadad33d12 100644 (file)
@@ -1314,10 +1314,12 @@ bool wxNotebook::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result)
   event.SetEventObject(this);
   event.SetInt(idCtrl);
 
-  bool processed = HandleWindowEvent(event);
+  // Change the selection before generating the event as its handler should
+  // already see the new page selected.
   if ( hdr->code == TCN_SELCHANGE )
       UpdateSelection(event.GetSelection());
 
+  bool processed = HandleWindowEvent(event);
   *result = !event.IsAllowed();
   return processed;
 }