diff --git a/include/wx/osx/window.h b/include/wx/osx/window.h index e327b0a55b..f761a598bc 100644 --- a/include/wx/osx/window.h +++ b/include/wx/osx/window.h @@ -157,6 +157,7 @@ public: void MacOnScroll( wxScrollEvent&event ); virtual bool AcceptsFocus() const wxOVERRIDE; + virtual void EnableVisibleFocus(bool enabled) wxOVERRIDE; virtual bool IsDoubleBuffered() const wxOVERRIDE { return true; } diff --git a/include/wx/window.h b/include/wx/window.h index 1c3cc3d759..e6d987812f 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -767,6 +767,9 @@ public: // call this when the return value of AcceptsFocus() changes virtual void SetCanFocus(bool WXUNUSED(canFocus)) { } + // call to customize visible focus indicator if possible in the port + virtual void EnableVisibleFocus(bool WXUNUSED(enabled)) { } + // navigates inside this window bool NavigateIn(int flags = wxNavigationKeyEvent::IsForward) { return DoNavigateIn(flags); } diff --git a/interface/wx/window.h b/interface/wx/window.h index 3776331ddc..9d1d235c9f 100644 --- a/interface/wx/window.h +++ b/interface/wx/window.h @@ -540,6 +540,22 @@ public: */ virtual void SetCanFocus(bool canFocus); + /** + Enables or disables visible indication of keyboard focus. + + By default, controls behave in platform-appropriate way and show focus + in the same way native applications do. In some very rare circumstances + it may be desirable to change the default (notably multiline text + controls don't normally have a focus indicator on Mac), which this + method allows. It should only be used if you have a good understanding + of the native platform's guidelines and user expectations. + + This method is only implemented on Mac. + + @since 3.1.5 + */ + virtual void EnableVisibleFocus(bool enable); + /** This sets the window to receive keyboard input. diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index 1d91b52a13..6e349163ff 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -2171,6 +2171,11 @@ bool wxWindowMac::AcceptsFocus() const return GetPeer()->CanFocus(); } +void wxWindowMac::EnableVisibleFocus(bool enabled) +{ + GetPeer()->EnableFocusRing(enabled); +} + void wxWindowMac::MacSuperChangedPosition() { // only window-absolute structures have to be moved i.e. controls