]> git.saurik.com Git - wxWidgets.git/commitdiff
Set wxTAB_TRAVERSAL for wxNavigationEnabled<> windows with focusable children.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 13 Oct 2012 22:52:12 +0000 (22:52 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 13 Oct 2012 22:52:12 +0000 (22:52 +0000)
We need to have this flag under wxMSW in order for navigation events to be
generated for the window. As wxNavigationEnabled can't set this flag on
creation because its ctor is called too early, do it in overridden AddChild().

Closes #13271.

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

include/wx/containr.h

index 69dc4a92c62c1bcd2c0a424bc317566ef2710950..24e404a7f8fe5377887cfd43a4bce0cefa68c541 100644 (file)
@@ -73,7 +73,7 @@ public:
 
     // Returns whether we or one of our children accepts focus.
     bool AcceptsFocusRecursively() const
-    bool AcceptsFocus() const { return m_acceptsFocus; }
+        { return m_acceptsFocusSelf || m_acceptsFocusChildren; }
 
     // We accept focus from keyboard if we accept it at all.
     bool AcceptsFocusFromKeyboard() const { return AcceptsFocusRecursively(); }
@@ -205,7 +205,13 @@ public:
     {
         BaseWindowClass::AddChild(child);
 
-        m_container.UpdateCanFocusChildren();
+        if ( m_container.UpdateCanFocusChildren() )
+        {
+            // Under MSW we must have wxTAB_TRAVERSAL style for TAB navigation
+            // to work.
+            if ( !BaseWindowClass::HasFlag(wxTAB_TRAVERSAL) )
+                BaseWindowClass::ToggleWindowStyle(wxTAB_TRAVERSAL);
+        }
     }
 
     WXDLLIMPEXP_INLINE_CORE virtual void RemoveChild(wxWindowBase *child)
@@ -216,6 +222,8 @@ public:
 
         BaseWindowClass::RemoveChild(child);
 
+        // We could reset wxTAB_TRAVERSAL here but it doesn't seem to do any
+        // harm to keep it.
         m_container.UpdateCanFocusChildren();
     }