X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3d3afaecfb60725ac2dc86e10a46f8a5d7899810..841f23e18a9d9e3d987b60422c3a220571868337:/src/common/containr.cpp?ds=inline diff --git a/src/common/containr.cpp b/src/common/containr.cpp index b4b63b63af..020bc20ca1 100644 --- a/src/common/containr.cpp +++ b/src/common/containr.cpp @@ -28,17 +28,10 @@ #include "wx/log.h" #include "wx/event.h" #include "wx/window.h" -#endif //WX_PRECOMP - -#include "wx/containr.h" - -#ifdef __WXMAC__ #include "wx/scrolbar.h" -#endif - -#ifdef __WXMSW__ #include "wx/radiobut.h" -#endif + #include "wx/containr.h" +#endif //WX_PRECOMP // trace mask for focus messages #define TRACE_FOCUS _T("focus") @@ -302,7 +295,7 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) } // where are we going? - bool forward = event.GetDirection(); + const bool forward = event.GetDirection(); // the node of the children list from which we should start looking for the // next acceptable child @@ -319,11 +312,8 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) // start from first or last depending on where we're going node = forward ? children.GetFirst() : children.GetLast(); - - // we want to cycle over all nodes - start_node = wxWindowList::compatibility_iterator(); } - else + else // going up { // try to find the child which has the focus currently @@ -349,10 +339,6 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) // ok, we found the focus - now is it our child? start_node = children.Find( winFocus ); } - else - { - start_node = wxWindowList::compatibility_iterator(); - } if ( !start_node && m_winLastFocused ) { @@ -373,14 +359,24 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) } // we want to cycle over all elements passing by NULL - while ( node != start_node ) + for ( ;; ) { + // don't go into infinite loop + if ( start_node && node && node == start_node ) + break; + // Have we come to the last or first item on the panel? if ( !node ) { + if ( !start_node ) + { + // exit now as otherwise we'd loop forever + break; + } + if ( !goingDown ) { - // Check if our (may be grand) parent is another panel: if this + // Check if our (maybe grand) parent is another panel: if this // is the case, they will know what to do with this navigation // key and so give them the chance to process it instead of // looping inside this panel (normally, the focus will go to @@ -643,4 +639,3 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused) return false; } -