]> git.saurik.com Git - wxWidgets.git/commitdiff
in wxAuiNotebook, prevent unwanted page selection changes during tab drags
authorBenjamin Williams <bwilliams@kirix.com>
Sun, 1 Jul 2007 15:39:22 +0000 (15:39 +0000)
committerBenjamin Williams <bwilliams@kirix.com>
Sun, 1 Jul 2007 15:39:22 +0000 (15:39 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47057 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/aui/auibook.h
src/aui/auibook.cpp

index 77735854f3d12b2d22402cd517b975ae813b59a1..897cc17e2a1e16a62e412eeea590c889c473b55c 100644 (file)
@@ -446,6 +446,10 @@ public:
 
     ~wxAuiTabCtrl();
 
+#if wxABI_VERSION >= 20805
+    bool IsDragging() const { return m_is_dragging; }
+#endif
+
 protected:
 
     void OnPaint(wxPaintEvent& evt);
index 5b40085343641195bb4910c1567b9422e5dd41c1..42a93ec55cc697d7f0f635f057ba537c984a4e3f 100644 (file)
@@ -2067,11 +2067,14 @@ void wxAuiTabCtrl::OnLeftUp(wxMouseEvent& evt)
 
     if (m_is_dragging)
     {
+        m_is_dragging = false;
+        
         wxAuiNotebookEvent evt(wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, m_windowId);
         evt.SetSelection(GetIdxFromWindow(m_click_tab));
         evt.SetOldSelection(evt.GetSelection());
         evt.SetEventObject(this);
         GetEventHandler()->ProcessEvent(evt);
+         
         return;
     }
 
@@ -3662,6 +3665,27 @@ void wxAuiNotebook::RemoveEmptyTabFrames()
 
 void wxAuiNotebook::OnChildFocus(wxChildFocusEvent& evt)
 {
+    // if we're dragging a tab, don't change the current selection.
+    // This code prevents a bug that used to happen when the hint window
+    // was hidden.  In the bug, the focus would return to the notebook
+    // child, which would then enter this handler and call
+    // SetSelection, which is not desired turn tab dragging.
+    
+    wxAuiPaneInfoArray& all_panes = m_mgr.GetAllPanes();
+    size_t i, pane_count = all_panes.GetCount();
+    for (i = 0; i < pane_count; ++i)
+    {
+        wxAuiPaneInfo& pane = all_panes.Item(i);
+        if (pane.name == wxT("dummy"))
+            continue;
+        wxTabFrame* tabframe = (wxTabFrame*)pane.window;
+        if (tabframe->m_tabs->IsDragging())
+            return;
+    }
+
+
+    // change the tab selection to the child
+    // which was focused
     int idx = m_tabs.GetIdxFromWindow(evt.GetWindow());
     if (idx != -1 && idx != m_curpage)
     {