gpt4 book ai didi

cocoa - NSComboBox 对焦环未正确对齐

转载 作者:行者123 更新时间:2023-12-03 16:19:25 24 4
gpt4 key购买 nike

当我创建 NSComboBox 并将控件尺寸设置为较小时,聚焦环未正确对齐。我在 xcode 界面中注意到同样的问题(cfr.截图)。

欢迎您的帮助。

enter image description here

最佳答案

我今天在 bugreport.apple.com 上报告了这一点作为雷达# 20852031

我的解决方法是子类化 NSComboBoxCell:

- (void)drawFocusRingMaskWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
NSRect focusRect = cellFrame;

focusRect.origin.y += 1.0f;
focusRect.size.width -= 3.0f;
focusRect.size.height -= 5.0f;

// NSBezierPath *focusPath = [NSBezierPath bezierPathWithRoundedRect:focusRect
// xRadius:2.0f
// yRadius:2.0f];

NSBezierPath *focusPath = [NSBezierPath bezierPath];
CGFloat leftRadius = 2.0f;
CGFloat rightRadius = 5.0f;

[focusPath moveToPoint:NSMakePoint(focusRect.origin.x + leftRadius, focusRect.origin.y)];

[focusPath lineToPoint:NSMakePoint(focusRect.origin.x + focusRect.size.width - rightRadius, focusRect.origin.y)];
[focusPath curveToPoint:NSMakePoint(focusRect.origin.x + focusRect.size.width, focusRect.origin.y + rightRadius)
controlPoint1:NSMakePoint(focusRect.origin.x + focusRect.size.width, focusRect.origin.y)
controlPoint2:NSMakePoint(focusRect.origin.x + focusRect.size.width, focusRect.origin.y)];

[focusPath lineToPoint:NSMakePoint(focusRect.origin.x + focusRect.size.width, focusRect.origin.y + focusRect.size.height - rightRadius)];
[focusPath curveToPoint:NSMakePoint(focusRect.origin.x + focusRect.size.width - rightRadius, focusRect.origin.y + focusRect.size.height)
controlPoint1:NSMakePoint(focusRect.origin.x + focusRect.size.width, focusRect.origin.y + focusRect.size.height)
controlPoint2:NSMakePoint(focusRect.origin.x + focusRect.size.width, focusRect.origin.y + focusRect.size.height)];

[focusPath lineToPoint:NSMakePoint(focusRect.origin.x + leftRadius, focusRect.origin.y + focusRect.size.height)];
[focusPath curveToPoint:NSMakePoint(focusRect.origin.x, focusRect.origin.y + focusRect.size.height - leftRadius)
controlPoint1:NSMakePoint(focusRect.origin.x, focusRect.origin.y + focusRect.size.height)
controlPoint2:NSMakePoint(focusRect.origin.x, focusRect.origin.y + focusRect.size.height)];

[focusPath lineToPoint:NSMakePoint(focusRect.origin.x, focusRect.origin.y + leftRadius)];
[focusPath curveToPoint:NSMakePoint(focusRect.origin.x + leftRadius, focusRect.origin.y)
controlPoint1:NSMakePoint(focusRect.origin.x, focusRect.origin.y)
controlPoint2:NSMakePoint(focusRect.origin.x, focusRect.origin.y)];

[NSGraphicsContext saveGraphicsState];
{
[focusPath fill];
}
[NSGraphicsContext restoreGraphicsState];
}

关于cocoa - NSComboBox 对焦环未正确对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29333527/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com