Allow configuring visible focus on Mac

Add wxWindow::EnableVisibleFocus() for changing focus ring behavior on
macOS (currently not implemented elsewhere, although GTK+ has a
discouraged option to do it).
This commit is contained in:
Václav Slavík
2020-08-31 10:38:39 +02:00
parent 58c94d9ec0
commit 9f66b03c5c
4 changed files with 25 additions and 0 deletions

View File

@@ -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; }

View File

@@ -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); }

View File

@@ -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.

View File

@@ -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