• 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
NSCursor category
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSCursor category


  • Subject: NSCursor category
  • From: Hamish Allan <email@hidden>
  • Date: Wed, 30 Jun 2004 04:28:44 +0100

Hi,

I'm trying to implement tracking rects in an NSView contained within an NSScrollView. The NSView is regularly resized as the user zooms in and out of the view.

The tracking rects are related to features drawn in the NSView and should cause a change in cursor. "addCursorRect: cursor:" is ideal for this as it can be called from "resetCursorRects" which is called just after "discardCursorRects" when the NSView is resized or scrolled.

However, I want to do some other things such as hover text, but "addTrackingRect:owner:userData:assumeInside:"; cannot be used the same way, as there is no "resetTrackingRects" or equivalent method as far as I can see. Instead the tracking rects have to be individually removed when the NSView changes shape which is a pain because I don't want to keep track of them manually.

So firstly, am I missing something with tracking rects? Why are they so much more difficult to use than cursor rects?

Anyway, I decided to try implementing a category for NSCursor:

@implementation NSCursor (NotificationCursor)

+ (NSCursor *)notificationCursor
{
NSCursor *cursor = [NSCursor resizeLeftRightCursor];
[cursor setOnMouseEntered:YES];
return cursor;
}

- (void)mouseEntered:(NSEvent *)event
{
NSLog(@"mouseEntered");
// do extra stuff here
}

@end

and instead of calling

[view addCursorRect:rect cursor:[NSCursor resizeLeftRightCursor]];

I'm calling

[view addCursorRect:rect cursor:[NSCursor notificationCursor]];

instead. However, although the cursor changes correctly over my cursor rects, demonstrating that the notificationCursor method is working correctly, the mouseEntered method is never called.

Can anybody please advise me what I'm doing wrong? Incidentally I also tried to do this with a subclass instead of a category and that didn't trigger the mouseEntered method either.

Thanks,
Hamish
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: NSCursor category
      • From: Yann Bizeul <email@hidden>
  • Prev by Date: Re: Saving arrays with NSUserDefaults?
  • Next by Date: NSMatrix Question...
  • Previous by thread: Re: selector not recognized
  • Next by thread: Re: NSCursor category
  • Index(es):
    • Date
    • Thread