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/branches/WX_2_8_BRANCH@48137 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2007-08-16 19:25:38 +00:00
parent 511c456b72
commit edeec0cdfc

View File

@@ -2296,13 +2296,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;
@@ -3335,14 +3328,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);
@@ -3385,9 +3388,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;
}