From 1eea936f8f3a7d835688772b5fe0cd055f8a05f5 Mon Sep 17 00:00:00 2001 From: Steve Browne Date: Mon, 5 Jun 2017 01:17:52 -0400 Subject: [PATCH] Properly handle tab navigation for wxRadioBoxes on wxOSX. --- include/wx/osx/radiobox.h | 2 +- src/common/containr.cpp | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/wx/osx/radiobox.h b/include/wx/osx/radiobox.h index bbf61a7b37..d12539f343 100644 --- a/include/wx/osx/radiobox.h +++ b/include/wx/osx/radiobox.h @@ -16,7 +16,7 @@ class WXDLLIMPEXP_FWD_CORE wxBitmap ; class WXDLLIMPEXP_FWD_CORE wxRadioButton ; -class WXDLLIMPEXP_CORE wxRadioBox: public wxControl, public wxRadioBoxBase +class WXDLLIMPEXP_CORE wxRadioBox: public wxNavigationEnabled, public wxRadioBoxBase { wxDECLARE_DYNAMIC_CLASS(wxRadioBox); public: diff --git a/src/common/containr.cpp b/src/common/containr.cpp index 9904c6761a..380a13571a 100644 --- a/src/common/containr.cpp +++ b/src/common/containr.cpp @@ -38,6 +38,10 @@ // trace mask for focus messages #define TRACE_FOCUS wxT("focus") +#if (defined(__WXMSW__) || defined(__WXMAC__)) && wxUSE_RADIOBTN +#define USE_RADIOBTN_NAV +#endif + // ============================================================================ // implementation // ============================================================================ @@ -235,7 +239,7 @@ void wxControlContainer::SetLastFocus(wxWindow *win) // -------------------------------------------------------------------- // The following four functions are used to find other radio buttons -// within the same group. Used by wxSetFocusToChild on wxMSW +// within the same group. Used by wxSetFocusToChild // -------------------------------------------------------------------- #if wxUSE_RADIOBTN @@ -348,7 +352,7 @@ wxRadioButton* wxGetSelectedButtonInGroup(wxRadioButton *btn) return NULL; } -#endif // __WXMSW__ +#endif // wxUSE_RADIOBTN // ---------------------------------------------------------------------------- // Keyboard handling - this is the place where the TAB traversal logic is @@ -464,12 +468,12 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) if ( winFocus ) { -#if defined(__WXMSW__) && wxUSE_RADIOBTN +#if defined(USE_RADIOBTN_NAV) // If we are in a radio button group, start from the first item in the // group if ( event.IsFromTab() && wxIsKindOf(winFocus, wxRadioButton ) ) winFocus = wxGetFirstButtonInGroup((wxRadioButton*)winFocus); -#endif // __WXMSW__ +#endif // USE_RADIOBTN_NAV // ok, we found the focus - now is it our child? start_node = children.Find( winFocus ); } @@ -554,7 +558,7 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) continue; } -#if defined(__WXMSW__) && wxUSE_RADIOBTN +#if defined(USE_RADIOBTN_NAV) if ( event.IsFromTab() ) { if ( wxIsKindOf(child, wxRadioButton) ) @@ -611,7 +615,7 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event ) return; } } -#endif // __WXMSW__ +#endif // USE_RADIOBTN_NAV if ( child->CanAcceptFocusFromKeyboard() ) { @@ -748,7 +752,7 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused) if ( child->CanAcceptFocusFromKeyboard() && !child->IsTopLevel() ) { -#if defined(__WXMSW__) && wxUSE_RADIOBTN +#if defined(USE_RADIOBTN_NAV) // If a radiobutton is the first focusable child, search for the // selected radiobutton in the same group wxRadioButton* btn = wxDynamicCast(child, wxRadioButton); @@ -758,7 +762,7 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused) if (selected) child = selected; } -#endif // __WXMSW__ +#endif // USE_RADIOBTN_NAV wxLogTrace(TRACE_FOCUS, wxT("SetFocusToChild() => first child (0x%p)."),