From 754dc409695be462c6749b316a82665acf5932c3 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Thu, 16 Aug 2007 19:25:50 +0000 Subject: [PATCH] Implemented Firefox-like behaviour whereby clicking again on a tab focuses the tab, but otherwise the focus goes to the page itself. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48138 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/aui/auibook.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index 41d0ace16a..1676de5b21 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -2201,13 +2201,6 @@ void wxAuiTabCtrl::OnSize(wxSizeEvent& evt) void wxAuiTabCtrl::OnLeftDown(wxMouseEvent& evt) { - // Set the focus - if (FindFocus() != this) - { - SetFocus(); - Refresh(); - } - CaptureMouse(); m_click_pt = wxDefaultPosition; m_is_dragging = false; @@ -3237,14 +3230,24 @@ int wxAuiNotebook::GetSelection() const // SetSelection() sets the currently active page size_t wxAuiNotebook::SetSelection(size_t new_page) { - // don't change the page unless necessary - if ((int)new_page == m_curpage) - return m_curpage; - wxWindow* wnd = m_tabs.GetWindowFromIdx(new_page); if (!wnd) return m_curpage; + // don't change the page unless necessary; + // however, clicking again on a tab should give it the focus. + if ((int)new_page == m_curpage) + { + wxAuiTabCtrl* ctrl; + int ctrl_idx; + if (FindTab(wnd, &ctrl, &ctrl_idx)) + { + if (FindFocus() != ctrl) + ctrl->SetFocus(); + } + return m_curpage; + } + wxAuiNotebookEvent evt(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING, m_windowId); evt.SetSelection(new_page); evt.SetOldSelection(m_curpage); @@ -3287,9 +3290,10 @@ size_t wxAuiNotebook::SetSelection(size_t new_page) tabctrl->Refresh(); } - // We should set focus to the tab control if not already focused. - if (ctrl->IsShownOnScreen() && FindFocus() != ctrl) - ctrl->SetFocus(); + // Set the focus to the page if we're not currently focused on the tab. + // This is Firefox-like behaviour. + if (wnd->IsShownOnScreen() && FindFocus() != ctrl) + wnd->SetFocus(); return old_curpage; } -- 2.45.2