Draw wxTextCtrl focus ring natively on Mac
NSTextView doesn't display focus ring by default, which is why wxOSX did draw it manually, but this behavior can be overriden since OS X 10.3 with NSView.focusRingType property. The HITheme-based rendering suffered from a number of non-nativeness issues: - didn't respect macOS 10.14+ accent colors - not animated as the native focus ring - subtly different shape of the outline - noticeably different outline shape on macOS 11 Remove NeedsFocusRect() and associated workaround for manually drawing focus ring inside NSTextView (i.e. multiline text controls). This private interface was only used for wxTextCtrl and nothing else, so this shouldn't have any impact elsewhere.
This commit is contained in:
@@ -938,9 +938,6 @@ void wxWindowMac::MacInvalidateBorders()
|
||||
|
||||
int outerBorder = MacGetLeftBorderSize() ;
|
||||
|
||||
if ( GetPeer()->NeedsFocusRect() )
|
||||
outerBorder += 4 ;
|
||||
|
||||
if ( outerBorder == 0 )
|
||||
return ;
|
||||
|
||||
@@ -1578,8 +1575,6 @@ void wxWindowMac::MacPaintBorders( int WXUNUSED(leftOrigin) , int WXUNUSED(right
|
||||
|
||||
#if wxOSX_USE_COCOA_OR_CARBON
|
||||
{
|
||||
const bool hasFocus = GetPeer()->NeedsFocusRect() && HasFocus();
|
||||
|
||||
CGRect cgrect = CGRectMake( tx-1 , ty-1 , tw+2 ,
|
||||
th+2 ) ;
|
||||
|
||||
@@ -1594,7 +1589,6 @@ void wxWindowMac::MacPaintBorders( int WXUNUSED(leftOrigin) , int WXUNUSED(right
|
||||
info.version = 0 ;
|
||||
info.kind = 0 ;
|
||||
info.state = IsEnabled() ? kThemeStateActive : kThemeStateInactive ;
|
||||
info.isFocused = hasFocus ;
|
||||
|
||||
if ( HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
|
||||
{
|
||||
@@ -1607,11 +1601,6 @@ void wxWindowMac::MacPaintBorders( int WXUNUSED(leftOrigin) , int WXUNUSED(right
|
||||
HIThemeDrawFrame( &cgrect , &info , cgContext , kHIThemeOrientationNormal ) ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( hasFocus )
|
||||
{
|
||||
HIThemeDrawFocusRect( &cgrect , true , cgContext , kHIThemeOrientationNormal ) ;
|
||||
}
|
||||
}
|
||||
#endif // wxOSX_USE_COCOA_OR_CARBON
|
||||
}
|
||||
@@ -2746,20 +2735,9 @@ void wxWidgetImpl::Init()
|
||||
m_wantsUserKey = false;
|
||||
m_wantsUserMouse = false;
|
||||
m_wxPeer = NULL;
|
||||
m_needsFocusRect = false;
|
||||
m_needsFrame = true;
|
||||
}
|
||||
|
||||
void wxWidgetImpl::SetNeedsFocusRect( bool needs )
|
||||
{
|
||||
m_needsFocusRect = needs;
|
||||
}
|
||||
|
||||
bool wxWidgetImpl::NeedsFocusRect() const
|
||||
{
|
||||
return m_needsFocusRect;
|
||||
}
|
||||
|
||||
void wxWidgetImpl::SetNeedsFrame( bool needs )
|
||||
{
|
||||
m_needsFrame = needs;
|
||||
|
Reference in New Issue
Block a user