Properly handle tab navigation for wxRadioBoxes on wxOSX.

This commit is contained in:
Steve Browne
2017-06-05 01:17:52 -04:00
parent 39cfbe3b94
commit 1eea936f8f
2 changed files with 13 additions and 9 deletions

View File

@@ -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<wxControl>, public wxRadioBoxBase
{
wxDECLARE_DYNAMIC_CLASS(wxRadioBox);
public:

View File

@@ -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)."),