I have implemented an iOS style NSScrollView by adding a knob subview to the 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.
- (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.
How can I prevent this? Has it something to do with the knob view not being opaque?
UPDATE 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.
UPDATE 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.
Setting up an NSTrackingArea
in the NSScroller
with the NSTrackingMouseMoved
option set and implementing
- (void)mouseMoved:(NSEvent *)theEvent {
[[NSCursor pointingHandCursor] set];
}
does the trick.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.