• 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
Cursor updates - bug or programmer ignorance?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cursor updates - bug or programmer ignorance?


  • Subject: Cursor updates - bug or programmer ignorance?
  • From: Luke Evans <email@hidden>
  • Date: Mon, 19 Jan 2009 11:00:10 -0800

I was surprised by some cursor behaviour and whittled down the following code (the only code in an NSTableView subclass):

- (void)updateTrackingAreas {
NSLog(@"Tracking update");
for (NSTrackingArea *area in [self trackingAreas]) {
if ([area owner] == self) {
[self removeTrackingArea:area];
}
}
//NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[self bounds] options:NSTrackingCursorUpdate | NSTrackingActiveAlways owner:self userInfo:nil];
NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[self bounds] options:NSTrackingCursorUpdate | NSTrackingActiveInActiveApp owner:self userInfo:nil];
[self addTrackingArea:area];
}


- (void)cursorUpdate:(NSEvent *)event {
	[[NSCursor openHandCursor] set];
	NSLog(@"Cursor updated");
}

This code correctly sets the cursor to the open hand cursor when the mouse is moved over the table view. I tried both NSTrackingActiveAlways and NSTrackingActiveInActiveApp because of some note in the docs that talks about the interaction of NSTrackingCursorUpdate and NSTrackingActiveAlways - but the behaviour here is the same.

The odd behaviour is that the cursor is reset back to the regular arrowCursor after a few seconds, with the cursor still over the view. At this point I don't know 'who' is doing this or why; nor how to stop it.

The -updateTrackingAreas method is called exactly once in my simple test (I wondered if some change in the state of the tracking areas would reset the cursor state - but evidently it's not as simple as that).

There's a good chance that I'm displaying continued ignorance of Cocoa - but I've been through the docs several times for clues without enlightenment. Surely the system should be able to change the cursor on you without giving you a chance to reassert the cursor you want (even if it does this on some kind of timer to avoid stale cursor states from poorly written application code - or whatever).

Is there a parallel mechanism to the tracking areas here that I should also be interacting with to ensure that my cursor stays set the way I want it?

Cheers

-- Luke




_______________________________________________

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: Cursor updates - bug or programmer ignorance?
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: CALayer unwanted blurring
  • Next by Date: "Cocoa Fundamentals Guide" Clarification
  • Previous by thread: Re: SIGPIPE with sockets
  • Next by thread: Re: Cursor updates - bug or programmer ignorance?
  • Index(es):
    • Date
    • Thread