NSCursor category
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:user
Data: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.