X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/feb32e31659d9fc8fa30ba80c3504b50ade89636..4e15d1caa03346c126015019c1fdf093033ef40b:/src/msw/notebook.cpp diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 5990c012bc..1d69e439bb 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -375,17 +375,22 @@ void wxNotebook::UpdateSelection(int selNew) { wxNotebookPage *pPage = m_pages[selNew]; pPage->Show(true); - } - - // Changing the page should give the focus to it but, as per bug report - // http://sf.net/tracker/index.php?func=detail&aid=1150659&group_id=9863&atid=109863, - // we should not set the focus to it directly since it erroneously - // selects radio buttons and breaks keyboard handling for a notebook's - // scroll buttons. So give focus to the notebook and not the page. - // but don't do this is the notebook is hidden - if ( ::IsWindowVisible(GetHwnd()) ) - SetFocus(); + // In addition to showing the page, we also want to give focus to it to + // make it possible to work with it from keyboard easily. However there + // are two exceptions: first, don't touch the focus at all if the + // notebook itself is not currently shown. + if ( ::IsWindowVisible(GetHwnd()) ) + { + // And second, don't give focus away if the tab control itself has + // it, as this is how the native property sheets behave: if you + // explicitly click on the tab label giving it focus, it will + // remain after switching to another page. But if the focus was + // inside the notebook page, it switches to the new page. + if ( !HasFocus() ) + pPage->SetFocus(); + } + } m_selection = selNew; } @@ -412,7 +417,7 @@ bool wxNotebook::SetPageText(size_t nPage, const wxString& strText) TC_ITEM tcItem; tcItem.mask = TCIF_TEXT; - tcItem.pszText = (wxChar *)strText.wx_str(); + tcItem.pszText = wxMSW_CONV_LPTSTR(strText); if ( !HasFlag(wxNB_MULTILINE) ) return TabCtrl_SetItem(GetHwnd(), nPage, &tcItem) != 0; @@ -686,7 +691,7 @@ bool wxNotebook::InsertPage(size_t nPage, if ( !strText.empty() ) { tcItem.mask |= TCIF_TEXT; - tcItem.pszText = const_cast(strText.wx_str()); + tcItem.pszText = wxMSW_CONV_LPTSTR(strText); } // hide the page: unless it is selected, it shouldn't be shown (and if it