]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix tab navigation into radio boxes in wxMSW.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 23 Jul 2013 00:43:33 +0000 (00:43 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 23 Jul 2013 00:43:33 +0000 (00:43 +0000)
Radio boxes refused to take focus from keyboard as their
wxControlContainer::AcceptsFocusFromKeyboard() always returned false because
the base wxStaticBox class disabled setting the focus to the control itself
and wxRadioBox doesn't have any children at wx level in wxMSW.

Fix this by reenabling "self focus" in wxRadioBox to make it possible to
accept focus from keyboard. This is not ideal as it doesn't take into account
e.g. radio boxes without any items or with all items disabled or hidden, but
this should be rare and would require virtualizing all children access at
wxControlContainer level, i.e. would be quite non-trivial so don't do this for
now as this, at least, fixes the navigation in common/normal case.

Also remove the unnecessary AcceptsFocus() override from wxRadioBox as this is
now done at wxControlContainer level.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74583 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/containr.h
include/wx/msw/radiobox.h
src/msw/radiobox.cpp

index 98382778e2abf1c0062c57dd70f0d175d6302793..903cfcbf7f2a4ce52909edcca09c61acb1a50c5f 100644 (file)
@@ -565,6 +565,10 @@ All (GUI):
 - Fix crash in wxHTML on mal-formed <area> elements (LukasK).
 - Set correct cursor when the mouse is over image map links in wxHTML (LukasK).
 
+wxMSW:
+
+- It is now possible to tab into radio boxes again.
+
 
 2.9.5: (released 2013-07-15)
 ----------------------------
index 0549e6be09a0ab2e0bd6e5bb6aceb0d3de83a6b9..3783578f402e669102012da114e5a143d30521f5 100644 (file)
@@ -62,7 +62,14 @@ public:
 
     // This can be called by the window to indicate that it never wants to have
     // the focus for itself.
-    void DisableSelfFocus() { m_acceptsFocusSelf = false; }
+    void DisableSelfFocus()
+        { m_acceptsFocusSelf = false; UpdateParentCanFocus(); }
+
+    // This can be called to undo the effect of a previous DisableSelfFocus()
+    // (otherwise calling it is not necessary as the window does accept focus
+    // by default).
+    void EnableSelfFocus()
+        { m_acceptsFocusSelf = true; UpdateParentCanFocus(); }
 
     // should be called from SetFocus(), returns false if we did nothing with
     // the focus and the default processing should take place
index 5e3c362e51dfae3c619ca6bf037973637cd1cfe0..a0f546df9dd998173d668ebabcecdcc636c276f5 100644 (file)
@@ -113,10 +113,6 @@ public:
 
     virtual bool Reparent(wxWindowBase *newParent);
 
-    // we inherit a version always returning false from wxStaticBox, override
-    // it to behave normally
-    virtual bool AcceptsFocus() const { return wxControl::AcceptsFocus(); }
-
     // returns true if the platform should explicitly apply a theme border
     virtual bool CanApplyThemeBorder() const { return false; }
 
index 70665bdf845c7c589b698c79312223a75deab9f5..7f811c921651530846ec9c039aefa0d188dbe83b 100644 (file)
@@ -256,6 +256,12 @@ bool wxRadioBox::Create(wxWindow *parent,
     const wxSize actualSize = GetSize();
     PositionAllButtons(pos.x, pos.y, actualSize.x, actualSize.y);
 
+    // The base wxStaticBox class never accepts focus, but we do because giving
+    // focus to a wxRadioBox actually gives it to one of its buttons, which are
+    // not visible at wx level and hence are not taken into account by the
+    // logic in wxControlContainer code.
+    m_container.EnableSelfFocus();
+
     return true;
 }