diff --git a/include/wx/aui/auibook.h b/include/wx/aui/auibook.h index 0c48988dd4..f7c96242eb 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 8f8285539d..7c4400e391 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; } @@ -3659,6 +3662,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) {