+
+ // if we're setting the focus to a child panel we should prevent it
+ // from giving it to the child which had the focus the last time
+ // and instead give it to the first/last child depending from which
+ // direction we're coming
+ wxPanel *subpanel = wxDynamicCast(child, wxPanel);
+ if ( subpanel )
+ {
+ // trick the panel into thinking that it got the navigation
+ // event - instead of duplicating all the code here
+ //
+ // make sure that we do trick it by setting all the parameters
+ // correctly (consistently with the code in this very function
+ // above) and that it starts from the very beginning/end by
+ // using SetLastFocus(NULL)
+ subpanel->SetLastFocus((wxWindow *)NULL);
+ }
+
+ event.SetEventObject(this);
+ if ( !child->GetEventHandler()->ProcessEvent(event) )
+ {
+ // everything is simple: just give focus to it
+ child->SetFocus();
+ }
+ //else: the child manages its focus itself
+
+ event.Skip( FALSE );