From 9b3f654a4cd6b96339a495145a9fbd96c1d14197 Mon Sep 17 00:00:00 2001 From: Benjamin Williams Date: Wed, 8 Nov 2006 07:44:07 +0000 Subject: [PATCH] button bug fix git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43185 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/aui/auibook.h | 1 + src/aui/auibook.cpp | 32 ++++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/include/wx/aui/auibook.h b/include/wx/aui/auibook.h index 7bfabe35e1..06afedaafb 100644 --- a/include/wx/aui/auibook.h +++ b/include/wx/aui/auibook.h @@ -456,6 +456,7 @@ protected: wxWindow* m_click_tab; bool m_is_dragging; wxAuiTabContainerButton* m_hover_button; + wxAuiTabContainerButton* m_pressed_button; #ifndef SWIG DECLARE_CLASS(wxAuiTabCtrl) diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index 2d8805b1b5..1d9711aa1c 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -1834,6 +1834,7 @@ wxAuiTabCtrl::wxAuiTabCtrl(wxWindow* parent, m_click_pt = wxDefaultPosition; m_is_dragging = false; m_hover_button = NULL; + m_pressed_button = NULL; } wxAuiTabCtrl::~wxAuiTabCtrl() @@ -1867,14 +1868,12 @@ void wxAuiTabCtrl::OnLeftDown(wxMouseEvent& evt) m_click_pt = wxDefaultPosition; m_is_dragging = false; m_click_tab = NULL; + m_pressed_button = NULL; wxWindow* wnd; if (TabHitTest(evt.m_x, evt.m_y, &wnd)) - { - if (m_flags & wxAUI_NB_CLOSE_ON_ACTIVE_TAB) - m_hover_button = NULL; - + { wxAuiNotebookEvent e(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, m_windowId); e.SetSelection(GetIdxFromWindow(wnd)); e.SetOldSelection(GetActivePage()); @@ -1888,13 +1887,14 @@ void wxAuiTabCtrl::OnLeftDown(wxMouseEvent& evt) if (m_hover_button) { - m_hover_button->cur_state = wxAUI_BUTTON_STATE_PRESSED; + m_pressed_button = m_hover_button; + m_pressed_button->cur_state = wxAUI_BUTTON_STATE_PRESSED; Refresh(); Update(); } } -void wxAuiTabCtrl::OnLeftUp(wxMouseEvent&) +void wxAuiTabCtrl::OnLeftUp(wxMouseEvent& evt) { if (GetCapture() == this) ReleaseMouse(); @@ -1909,19 +1909,31 @@ void wxAuiTabCtrl::OnLeftUp(wxMouseEvent&) return; } - if (m_hover_button) + if (m_pressed_button) { - m_hover_button->cur_state = wxAUI_BUTTON_STATE_HOVER; + // make sure we're still clicking the button + wxAuiTabContainerButton* button = NULL; + if (!ButtonHitTest(evt.m_x, evt.m_y, &button)) + return; + + if (button != m_pressed_button) + { + m_pressed_button = NULL; + return; + } + Refresh(); Update(); - if (!(m_hover_button->cur_state & wxAUI_BUTTON_STATE_DISABLED)) + if (!(m_pressed_button->cur_state & wxAUI_BUTTON_STATE_DISABLED)) { wxAuiNotebookEvent evt(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, m_windowId); - evt.SetInt(m_hover_button->id); + evt.SetInt(m_pressed_button->id); evt.SetEventObject(this); GetEventHandler()->ProcessEvent(evt); } + + m_pressed_button = NULL; } m_click_pt = wxDefaultPosition; -- 2.45.2