From: Benjamin Williams Date: Thu, 28 Jun 2007 13:11:19 +0000 (+0000) Subject: fix for wxAuiNotebook middle-click close (was closing wrong page) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/9b362935966dd8e7ae1aeb7a7ab857cef5687a07 fix for wxAuiNotebook middle-click close (was closing wrong page) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47000 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index 8f8388ff16..5b40085343 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -2094,6 +2094,7 @@ void wxAuiTabCtrl::OnLeftUp(wxMouseEvent& evt) if (!(m_pressed_button->cur_state & wxAUI_BUTTON_STATE_DISABLED)) { wxAuiNotebookEvent evt(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, m_windowId); + evt.SetSelection(GetIdxFromWindow(m_click_tab)); evt.SetInt(m_pressed_button->id); evt.SetEventObject(this); GetEventHandler()->ProcessEvent(evt); @@ -2744,6 +2745,12 @@ bool wxAuiNotebook::DeletePage(size_t page_idx) // but does not destroy the window bool wxAuiNotebook::RemovePage(size_t page_idx) { + // save active window pointer + wxWindow* active_wnd = NULL; + if (m_curpage >= 0) + active_wnd = m_tabs.GetWindowFromIdx(m_curpage); + + // save pointer of window being deleted wxWindow* wnd = m_tabs.GetWindowFromIdx(page_idx); wxWindow* new_active = NULL; @@ -2789,6 +2796,11 @@ bool wxAuiNotebook::RemovePage(size_t page_idx) } } } + else + { + // we are not deleting the active page, so keep it the same + new_active = active_wnd; + } if (!new_active) @@ -3667,13 +3679,12 @@ void wxAuiNotebook::OnTabButton(wxCommandEvent& command_evt) if (button_id == wxAUI_BUTTON_CLOSE) { - int selection = tabs->GetActivePage(); + int selection = evt.GetSelection(); if (selection != -1) { wxWindow* close_wnd = tabs->GetWindowFromIdx(selection); - // ask owner if it's ok to close the tab wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, m_windowId); e.SetSelection(m_tabs.GetIdxFromWindow(close_wnd));