From: Benjamin Williams Date: Sun, 1 Jul 2007 15:39:22 +0000 (+0000) Subject: in wxAuiNotebook, prevent unwanted page selection changes during tab drags X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/d16619f8d0f0a3bff7dd51cf57d1ba0f70176309 in wxAuiNotebook, prevent unwanted page selection changes during tab drags git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47057 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/aui/auibook.h b/include/wx/aui/auibook.h index 77735854f3..897cc17e2a 100644 --- a/include/wx/aui/auibook.h +++ b/include/wx/aui/auibook.h @@ -446,6 +446,10 @@ public: ~wxAuiTabCtrl(); +#if wxABI_VERSION >= 20805 + bool IsDragging() const { return m_is_dragging; } +#endif + protected: void OnPaint(wxPaintEvent& evt); diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index 5b40085343..42a93ec55c 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -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) {