• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Change NSCursor globally
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Change NSCursor globally


  • Subject: Re: Change NSCursor globally
  • From: Colas B <email@hidden>
  • Date: Wed, 15 Feb 2017 10:24:47 +0000 (UTC)

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@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Change NSCursor globally
      • From: Uli Kusterer <email@hidden>
References: 
 >Change NSCursor globally (From: Colas <email@hidden>)
 >Re: Change NSCursor globally (From: Uli Kusterer <email@hidden>)

  • Prev by Date: NSArrayController still doesn't support NSOrderedSet? (was: Are instances of a NSManagedObject subclass usable as regular objects?)
  • Next by Date: Problem with NSWindowCollectionBehaviorCanJoinAllSpaces
  • Previous by thread: Re: Change NSCursor globally
  • Next by thread: Re: Change NSCursor globally
  • Index(es):
    • Date
    • Thread