Hi Uli,
thanks for your answer.I want to do the former: when the user enables a mode in
the application, the cursor changes, exactly in the way you described (the
shape changes). The user should be able to use this custom cursor over a
PDFView, a UIScrollView, etc. However, I need the cursor only in one window.
Later the user can leave this mode and go back to the normal behaviour.I'm
looking for a solution that does not require subclassing all the views.
Here what I have done so far (it kind of works but flashes...):I set
contentView of NSWindow to a subclass CBDTrackedView of NSView with
@implementation CBDTrackedView
- (void)viewWillMoveToWindow:(NSWindow *)newWindow{ NSTrackingArea
*trackingArea = [CBDCursorManager trackingArea]; [self
addTrackingArea:trackingArea];}
@end
Then, CBDCursorManager is as follows:
- (instancetype)init{ self = [super init]; if (self) {
_trackingArea = [[NSTrackingArea alloc]
initWithRect:CGRectMake(-CGFLOAT_MAX/2,-CGFLOAT_MAX/2,CGFLOAT_MAX,CGFLOAT_MAX)
options:NSTrackingActiveInActiveApp | NSTrackingMouseEnteredAndExited |
NSTrackingMouseMoved | NSTrackingCursorUpdate
owner:self
userInfo:nil]; } return self;}
(...)
- (NSCursor *)cursorForIPhone6{ if (!_cursorForIPhone6) { NSImage
*image = [NSImage imageNamed:@"cursorIPhone6"]; NSCursor *cursor
= [[NSCursor alloc] initWithImage:image
hotSpot:NSMakePoint(620, 296)]; _cursorForIPhone6 = cursor;
} return _cursorForIPhone6;}- (void)mouseEntered:(NSEvent *)event{
[self.cursorForIPhone6 set];}
- (void)mouseExited:(NSEvent *)event{ [self.cursorForIPhone6 set];}
- (void)mouseMoved:(NSEvent *)event{ [self.cursorForIPhone6 set];}
- (void)cursorUpdate:(NSEvent *)event{ [self.cursorForIPhone6 set];}
Colas
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]