merged focus handling fix from 2.2
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9752 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -353,6 +353,8 @@ bool wxPanel::SetFocusToChild()
|
|||||||
|
|
||||||
bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused)
|
bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused)
|
||||||
{
|
{
|
||||||
|
wxCHECK_MSG( win, FALSE, _T("wxSetFocusToChild(): invalid window") );
|
||||||
|
|
||||||
if ( *childLastFocused )
|
if ( *childLastFocused )
|
||||||
{
|
{
|
||||||
// It might happen that the window got reparented or no longer accepts
|
// It might happen that the window got reparented or no longer accepts
|
||||||
|
@@ -727,18 +727,35 @@ void wxFrame::OnActivate(wxActivateEvent& event)
|
|||||||
// restore focus to the child which was last focused
|
// restore focus to the child which was last focused
|
||||||
wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd);
|
wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd);
|
||||||
|
|
||||||
wxSetFocusToChild(this, &m_winLastFocused);
|
wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent()
|
||||||
}
|
: NULL;
|
||||||
else
|
if ( !parent )
|
||||||
{
|
|
||||||
// remember the last focused child
|
|
||||||
m_winLastFocused = FindFocus();
|
|
||||||
while ( m_winLastFocused )
|
|
||||||
{
|
{
|
||||||
if ( GetChildren().Find(m_winLastFocused) )
|
parent = this;
|
||||||
break;
|
}
|
||||||
|
|
||||||
m_winLastFocused = m_winLastFocused->GetParent();
|
wxSetFocusToChild(parent, &m_winLastFocused);
|
||||||
|
}
|
||||||
|
else // deactivating
|
||||||
|
{
|
||||||
|
// remember the last focused child if it is our child
|
||||||
|
m_winLastFocused = FindFocus();
|
||||||
|
|
||||||
|
// so we NULL it out if it's a child from some other frame
|
||||||
|
wxWindow *win = m_winLastFocused;
|
||||||
|
while ( win )
|
||||||
|
{
|
||||||
|
if ( win->IsTopLevel() )
|
||||||
|
{
|
||||||
|
if ( win != this )
|
||||||
|
{
|
||||||
|
m_winLastFocused = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
win = win->GetParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLogTrace(_T("focus"),
|
wxLogTrace(_T("focus"),
|
||||||
|
Reference in New Issue
Block a user