diff --git a/include/wx/window.h b/include/wx/window.h index e574fe9df2..51104debd7 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -728,7 +728,11 @@ public: // can this window be given focus by keyboard navigation? if not, the // only way to give it focus (provided it accepts it at all) is to // click it - virtual bool AcceptsFocusFromKeyboard() const { return AcceptsFocus(); } + virtual bool AcceptsFocusFromKeyboard() const + { return !m_disableFocusFromKbd && AcceptsFocus(); } + + // Disable any input focus from the keyboard + void DisableFocusFromKeyboard() { m_disableFocusFromKbd = true; } // Can this window be focused right now, in its current state? This @@ -1733,6 +1737,9 @@ protected: bool m_inheritFgCol:1; bool m_inheritFont:1; + // flag disabling accepting focus from keyboard + bool m_disableFocusFromKbd:1; + // window attributes long m_windowStyle, m_exStyle; @@ -1929,7 +1936,6 @@ private: // (i.e. not being updated) if it is positive unsigned int m_freezeCount; - wxDECLARE_ABSTRACT_CLASS(wxWindowBase); wxDECLARE_NO_COPY_CLASS(wxWindowBase); wxDECLARE_EVENT_TABLE(); diff --git a/interface/wx/window.h b/interface/wx/window.h index 5898beef6a..5e3cd29ce2 100644 --- a/interface/wx/window.h +++ b/interface/wx/window.h @@ -487,6 +487,17 @@ public: */ virtual bool AcceptsFocusRecursively() const; + /** + Disable giving focus to this window using the keyboard navigation keys. + + Pressing @c TAB key will skip this window if this function was called + on it, but it will still be possible to focus it by clicking on it with + a pointing device. + + @since 3.1.4 + */ + void DisableFocusFromKeyboard(); + /** Can this window itself have focus? */ diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 0319a96e45..092c95f94e 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -320,6 +320,8 @@ wxWindowBase::wxWindowBase() m_containingSizer = NULL; m_autoLayout = false; + m_disableFocusFromKbd = true; + #if wxUSE_DRAG_AND_DROP m_dropTarget = NULL; #endif // wxUSE_DRAG_AND_DROP