[英]Cursor rect on top of NSTextView
I have implemented an iOS style NSScrollView by adding a knob subview to the NSScrollView. 我通过向NSScrollView添加旋钮子视图来实现iOS风格的NSScrollView。 The implementation works just fine except for one thing - the cursor change over the knob view.
该实现工作正常,除了一件事-光标在旋钮视图上切换。
I am using NSView
s -resetCursorRects
method to setup the cursor rectangle. 我正在使用
NSView
的-resetCursorRects
方法设置光标矩形。
- (void)resetCursorRects {
[self addCursorRect:self.knobFrame cursor:[NSCursor pointingHandCursor]];
}
This works too, but the Cursor is immediately reset to the IBeam
style as soon as I cross the cursor rect boundary. 这也可以,但是一旦我越过光标rect边界,Cursor就会立即重置为
IBeam
样式。
How can I prevent this? 我该如何预防? Has it something to do with the knob view not being opaque?
与旋钮视图不透明有关吗?
UPDATE 0: 更新0:
I also tried to implement it with a normal NSScroller
and forcing the scroller to overlay the NSClipView
in the scroll view's -tile
method, but it seems regardless of what view is placed on top of the NSTextView
it always enforces the IBeam
cursor type. 我也试图与正常执行它
NSScroller
并迫使滚轮以覆盖NSClipView
在滚动视图-tile
方法,但似乎无论是放置在顶部视图什么NSTextView
它总是强制执行IBeam
游标类型。
UPDATE 1: 更新1:
I found this mailing list entry that suggests overriding the NSTextView
s -mouseMoved
, but since this is not a satisfying solution for a robust custom NSScrollView
implementation its not really an option. 我发现此邮件列表条目建议重写
NSTextView
s -mouseMoved
,但是由于这对于健壮的自定义NSScrollView
实现而言并不是令人满意的解决方案, NSScrollView
它并不是一个真正的选择。
Setting up an NSTrackingArea
in the NSScroller
with the NSTrackingMouseMoved
option set and implementing 建立一个
NSTrackingArea
在NSScroller
与NSTrackingMouseMoved
选项设置和实施
- (void)mouseMoved:(NSEvent *)theEvent {
[[NSCursor pointingHandCursor] set];
}
does the trick. 绝招。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.