void wxPanel::Init()
{
- m_lastFocus = 0;
+ m_winLastFocused = (wxWindow *)NULL;
m_btnDefault = (wxButton *)NULL;
}
void wxPanel::OnFocus(wxFocusEvent& event)
{
- if (m_lastFocus != 0)
+ if ( m_winLastFocused )
{
- wxWindow* child = FindWindow(m_lastFocus);
- if (child)
- child->SetFocus();
+ // it might happen that the window got reparented...
+ if ( m_winLastFocused->GetParent() != this )
+ m_winLastFocused = (wxWindow *)NULL;
+ else
+ m_winLastFocused->SetFocus();
}
else
event.Skip();