Properly handle tab navigation for wxRadioBoxes on wxOSX.
This commit is contained in:
@@ -16,7 +16,7 @@ class WXDLLIMPEXP_FWD_CORE wxBitmap ;
|
|||||||
|
|
||||||
class WXDLLIMPEXP_FWD_CORE wxRadioButton ;
|
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);
|
wxDECLARE_DYNAMIC_CLASS(wxRadioBox);
|
||||||
public:
|
public:
|
||||||
|
@@ -38,6 +38,10 @@
|
|||||||
// trace mask for focus messages
|
// trace mask for focus messages
|
||||||
#define TRACE_FOCUS wxT("focus")
|
#define TRACE_FOCUS wxT("focus")
|
||||||
|
|
||||||
|
#if (defined(__WXMSW__) || defined(__WXMAC__)) && wxUSE_RADIOBTN
|
||||||
|
#define USE_RADIOBTN_NAV
|
||||||
|
#endif
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -235,7 +239,7 @@ void wxControlContainer::SetLastFocus(wxWindow *win)
|
|||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// The following four functions are used to find other radio buttons
|
// 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
|
#if wxUSE_RADIOBTN
|
||||||
@@ -348,7 +352,7 @@ wxRadioButton* wxGetSelectedButtonInGroup(wxRadioButton *btn)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __WXMSW__
|
#endif // wxUSE_RADIOBTN
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Keyboard handling - this is the place where the TAB traversal logic is
|
// Keyboard handling - this is the place where the TAB traversal logic is
|
||||||
@@ -464,12 +468,12 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event )
|
|||||||
|
|
||||||
if ( winFocus )
|
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
|
// If we are in a radio button group, start from the first item in the
|
||||||
// group
|
// group
|
||||||
if ( event.IsFromTab() && wxIsKindOf(winFocus, wxRadioButton ) )
|
if ( event.IsFromTab() && wxIsKindOf(winFocus, wxRadioButton ) )
|
||||||
winFocus = wxGetFirstButtonInGroup((wxRadioButton*)winFocus);
|
winFocus = wxGetFirstButtonInGroup((wxRadioButton*)winFocus);
|
||||||
#endif // __WXMSW__
|
#endif // USE_RADIOBTN_NAV
|
||||||
// ok, we found the focus - now is it our child?
|
// ok, we found the focus - now is it our child?
|
||||||
start_node = children.Find( winFocus );
|
start_node = children.Find( winFocus );
|
||||||
}
|
}
|
||||||
@@ -554,7 +558,7 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__WXMSW__) && wxUSE_RADIOBTN
|
#if defined(USE_RADIOBTN_NAV)
|
||||||
if ( event.IsFromTab() )
|
if ( event.IsFromTab() )
|
||||||
{
|
{
|
||||||
if ( wxIsKindOf(child, wxRadioButton) )
|
if ( wxIsKindOf(child, wxRadioButton) )
|
||||||
@@ -611,7 +615,7 @@ void wxControlContainer::HandleOnNavigationKey( wxNavigationKeyEvent& event )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // __WXMSW__
|
#endif // USE_RADIOBTN_NAV
|
||||||
|
|
||||||
if ( child->CanAcceptFocusFromKeyboard() )
|
if ( child->CanAcceptFocusFromKeyboard() )
|
||||||
{
|
{
|
||||||
@@ -748,7 +752,7 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused)
|
|||||||
|
|
||||||
if ( child->CanAcceptFocusFromKeyboard() && !child->IsTopLevel() )
|
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
|
// If a radiobutton is the first focusable child, search for the
|
||||||
// selected radiobutton in the same group
|
// selected radiobutton in the same group
|
||||||
wxRadioButton* btn = wxDynamicCast(child, wxRadioButton);
|
wxRadioButton* btn = wxDynamicCast(child, wxRadioButton);
|
||||||
@@ -758,7 +762,7 @@ bool wxSetFocusToChild(wxWindow *win, wxWindow **childLastFocused)
|
|||||||
if (selected)
|
if (selected)
|
||||||
child = selected;
|
child = selected;
|
||||||
}
|
}
|
||||||
#endif // __WXMSW__
|
#endif // USE_RADIOBTN_NAV
|
||||||
|
|
||||||
wxLogTrace(TRACE_FOCUS,
|
wxLogTrace(TRACE_FOCUS,
|
||||||
wxT("SetFocusToChild() => first child (0x%p)."),
|
wxT("SetFocusToChild() => first child (0x%p)."),
|
||||||
|
Reference in New Issue
Block a user