• 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: non-trivial NSCursor example?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: non-trivial NSCursor example?


  • Subject: Re: non-trivial NSCursor example?
  • From: Gérard Iglesias <email@hidden>
  • Date: Sun, 23 Sep 2001 00:53:19 -0700

Le samedi 22 septembre 2001, ` 10:35 , Michael B. Johnson a icrit :

> Hi folks. I'm trying to write a view that changes the cursor depending
> on what the hot keys the user is pressing, perhaps in conjunction with
> a mouseDown: (i.e. translating the view, zooming in, zooming out,
> etc.), and am looking for any example that shows how the right way to
> do this.
>
> Looking around, I'm coming up surprisingly blank (even Sketch just sets
> a crosshair cursor and is done with it). The doc on
> NSCursor/NSView/NSWindow is interesting, but not as clear as I'd like
> on how the flow should be.

I use the following approach that I think is conform and generic:

In case of special key changed I override flagsChanged:

//
**************************************************************************
***

- (void)flagsChanged:(NSEvent *)theEvent
{
[[self window] invalidateCursorRectsForView:self];
}

Then I overide resetCursorRect: , modified from ScreenGlass (look at
softtrack)

- (void)resetCursorRects
{
// set the cross cursor for the view rect
if(!posTimer_)
{
NSCursor * cursor;
NSEvent * event = [[self window] currentEvent];

if ([event modifierFlags] & NSShiftKeyMask)
cursor = [NSCursor IBeamCursor];
else
cursor = [NSCursor reticuleCursor];

[self addCursorRect:[self bounds] cursor:cursor];
[cursor setOnMouseEntered:YES];
}

// tracking rect
if (flags_.trackingRectNeedUpdate){
[self setTrackingRect];
flags_.trackingRectNeedUpdate = NO;
}
}

Hope this help.

Gerard


References: 
 >non-trivial NSCursor example? (From: "Michael B. Johnson" <email@hidden>)

  • Prev by Date: Re: Naive Pop-Up Button Example
  • Next by Date: link warning : prebind?
  • Previous by thread: non-trivial NSCursor example?
  • Next by thread: Running QuickTime Effects dialog from Cocoa
  • Index(es):
    • Date
    • Thread