]> git.saurik.com Git - wxWidgets.git/commitdiff
Implemented Firefox-like behaviour whereby clicking again on a tab focuses the tab...
authorJulian Smart <julian@anthemion.co.uk>
Thu, 16 Aug 2007 19:25:50 +0000 (19:25 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Thu, 16 Aug 2007 19:25:50 +0000 (19:25 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48138 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/aui/auibook.cpp

index 41d0ace16a4ec609da32115e120eb914c0be23ee..1676de5b211ff1be2335cae893735f621e015808 100644 (file)
@@ -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;
         }