gpt4 book ai didi

objective-c - 如何禁用 NSTextView 的 NSScrollView 滚动条上的鼠标悬停展开效果?

转载 作者:行者123 更新时间:2023-12-03 17:03:59 32 4
gpt4 key购买 nike

我有一个 NSTextView,这是滚动条的正常大小:
enter image description here
这是当我将鼠标悬停在 TextView 的滚动条上时发生的情况:
enter image description here
但是,我不想有这种“扩展”效果。我怎样才能删除它?我试图搜索如何执行此操作,但我找不到任何东西。我只想始终保持常规滚动条尺寸(较薄的滚动条),即使用户将其悬停也是如此。这可能吗?
谢谢

最佳答案

我建议继承 NSScroller 并覆盖 –drawArrow:highlight:/–drawKnobSlotInRect:highlight:/–drawKnob 方法,这样你就有了稳定的滚动条外观。

附注不要忘记在 XIB 文件中为滚动条设置新的滚动条类。

更新

这里是示例代码:

- (void)drawKnob
{
// call the default implementation for Overlay Scrollers
if (self.scrollerStyle == NSScrollerStyleOverlay)
{
[super drawKnob];
return;
}

if (_style == NSScrollerKnobStyleLight || _style == NSScrollerKnobStyleDefault)
[[NSColor colorWithCalibratedWhite:1.0 alpha:0.8] setFill];
else [[NSColor colorWithCalibratedWhite:0 alpha:0.4] setFill];

// Note: you can specify the rect with fixed width here
NSRect knobRect = [self rectForPart:NSScrollerKnob];

// VERTICAL SCROLLER
NSInteger fullWidth = knobRect.size.width;
knobRect.size.width = round(knobRect.size.width/2);
knobRect.origin.x += (NSInteger)((fullWidth - knobRect.size.width)/2);

// draw...
NSBezierPath * thePath = [NSBezierPath bezierPath];

[thePath appendBezierPathWithRoundedRect:knobRect xRadius:4 yRadius:4];
[thePath fill];
}

//---------------------------------------------------------------

- (void)drawKnobSlotInRect:(NSRect)slotRect highlight:(BOOL)flag
{
// call the default implementation for Overlay Scrollers
// draw nothing for usual
if (self.scrollerStyle == NSScrollerStyleOverlay)
{
[super drawKnobSlotInRect:slotRect highlight:flag];
}
}

//---------------------------------------------------------------

- (void)drawArrow:(NSScrollerArrow)whichArrow highlight:(BOOL)flag
{
// call the default implementation for Overlay Scrollers
// draw nothing for usual
if (self.scrollerStyle == NSScrollerStyleOverlay)
{
[super drawArrow:whichArrow highlight:flag];
}
}

关于objective-c - 如何禁用 NSTextView 的 NSScrollView 滚动条上的鼠标悬停展开效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16470694/

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