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:
Vadim Zeitlin
2001-04-14 21:46:54 +00:00
parent ed50e39ba2
commit e9456d8d5b
2 changed files with 29 additions and 10 deletions

View File

@@ -353,6 +353,8 @@ bool wxPanel::SetFocusToChild()
bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused)
{
wxCHECK_MSG( win, FALSE, _T("wxSetFocusToChild(): invalid window") );
if ( *childLastFocused )
{
// It might happen that the window got reparented or no longer accepts

View File

@@ -727,18 +727,35 @@ void wxFrame::OnActivate(wxActivateEvent& event)
// restore focus to the child which was last focused
wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd);
wxSetFocusToChild(this, &m_winLastFocused);
wxWindow *parent = m_winLastFocused ? m_winLastFocused->GetParent()
: NULL;
if ( !parent )
{
parent = this;
}
else
{
// remember the last focused child
m_winLastFocused = FindFocus();
while ( m_winLastFocused )
{
if ( GetChildren().Find(m_winLastFocused) )
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"),