X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c7bfb76a2cf367dcdbff8f9a97e3250053a1adca..d23d3b702b6d2dfc03d4ea66138f3053fce4aca7:/src/common/containr.cpp diff --git a/src/common/containr.cpp b/src/common/containr.cpp index 2f702e6f1a..b79bf180b1 100644 --- a/src/common/containr.cpp +++ b/src/common/containr.cpp @@ -316,7 +316,10 @@ wxRadioButton* wxGetSelectedButtonInGroup(wxRadioButton *btn) void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) { - wxWindow *parent = m_winParent->GetParent(); + // for a TLW we shouldn't involve the parent window, it has nothing to do + // with keyboard navigation inside this TLW + wxWindow *parent = m_winParent->IsTopLevel() ? NULL + : m_winParent->GetParent(); // the event is propagated downwards if the event emitter was our parent bool goingDown = event.GetEventObject() == parent; @@ -395,7 +398,7 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) { // just to be sure it's not used (normally this is not necessary, but // doesn't hurt neither) - m_winLastFocused = (wxWindow *)NULL; + m_winLastFocused = NULL; // start from first or last depending on where we're going node = forward ? children.GetFirst() : children.GetLast(); @@ -496,6 +499,14 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) wxWindow *child = node->GetData(); + // don't TAB to another TLW + if ( child->IsTopLevel() ) + { + node = forward ? node->GetNext() : node->GetPrevious(); + + continue; + } + #if defined(__WXMSW__) && wxUSE_RADIOBTN if ( event.IsFromTab() ) { @@ -521,24 +532,27 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) wxIsKindOf(m_winLastFocused, wxRadioButton) && !m_winLastFocused->HasFlag(wxRB_SINGLE) ) { + wxRadioButton * const + lastBtn = static_cast(m_winLastFocused); + // cursor keys don't navigate out of a radio button group so // find the correct radio button to focus if ( forward ) { - child = wxGetNextButtonInGroup((wxRadioButton*)m_winLastFocused); + child = wxGetNextButtonInGroup(lastBtn); if ( !child ) { // no next button in group, set it to the first button - child = wxGetFirstButtonInGroup((wxRadioButton*)m_winLastFocused); + child = wxGetFirstButtonInGroup(lastBtn); } } else { - child = wxGetPreviousButtonInGroup((wxRadioButton*)m_winLastFocused); + child = wxGetPreviousButtonInGroup(lastBtn); if ( !child ) { // no previous button in group, set it to the last button - child = wxGetLastButtonInGroup((wxRadioButton*)m_winLastFocused); + child = wxGetLastButtonInGroup(lastBtn); } } @@ -648,7 +662,7 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused) else { // it doesn't count as such any more - *childLastFocused = (wxWindow *)NULL; + *childLastFocused = NULL; } }