fix for handling (Shift-)Ctrl-Tab when the notebook itself has focus (patch 813507)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23957 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-09-27 12:34:05 +00:00
parent 724a907cbb
commit 1d5b3bf041

View File

@@ -727,6 +727,23 @@ void wxNotebook::OnSelChange(wxNotebookEvent& event)
{ {
wxNotebookPage *pPage = m_pages[sel]; wxNotebookPage *pPage = m_pages[sel];
pPage->Show(true); pPage->Show(true);
pPage->SetFocus();
// If the newly focused window is not a child of the new page,
// SetFocus was not successful and the notebook itself should be
// focused
wxWindow *currentFocus = FindFocus();
wxWindow *startFocus = currentFocus;
while ( currentFocus && currentFocus != pPage && currentFocus != this )
currentFocus = currentFocus->GetParent();
if ( startFocus == pPage || currentFocus != pPage )
SetFocus();
}
else // no pages in the notebook, give the focus to itself
{
SetFocus();
} }
m_nSelection = sel; m_nSelection = sel;
@@ -740,12 +757,14 @@ bool wxNotebook::MSWTranslateMessage(WXMSG *wxmsg)
{ {
const MSG * const msg = (MSG *)wxmsg; const MSG * const msg = (MSG *)wxmsg;
// we want to process (simple, i.e. without Shift or Ctrl) TAB to pass it // intercept TAB, CTRL+TAB and CTRL+SHIFT+TAB for processing by wxNotebook.
// to our page for keyboard navigation // TAB will be passed to the currently selected page, CTRL+TAB and
// CTRL+SHIFT+TAB will be processed by the notebook itself. do not
// intercept SHIFT+TAB. This goes to the parent of the notebook which will
// process it.
if ( msg->message == WM_KEYDOWN && msg->wParam == VK_TAB && if ( msg->message == WM_KEYDOWN && msg->wParam == VK_TAB &&
msg->hwnd == m_hwnd && msg->hwnd == m_hwnd &&
!wxIsCtrlDown() && !wxIsShiftDown() && (wxIsCtrlDown() || !wxIsShiftDown()) )
m_nSelection != -1 )
{ {
return MSWProcessMessage(wxmsg); return MSWProcessMessage(wxmsg);
} }