On Aug 25, 2010, at 12:30 PM, Richard Somers wrote: > On Aug 25, 2010, at 1:30 AM, Quincey Morris wrote: > >>> @implementation MyCustomDocumentView >>> >>> - (void)windowDidBecomeKeyNotification:(NSNotification *)notification >>> { >>> if ([notification object] == [self window]) { >>> NSPoint point = [[self window] mouseLocationOutsideOfEventStream]; >>> NSRect frame = [self convertRectToBase:[self frame]]; >>> BOOL condition = NSMouseInRect(point, frame, NO); >>> if (condition) { >>> [[NSCursor crosshairCursor] set]; // Called but does not work! >>> } >>> } >>> } >>> >>> @end >> >> The implication of this is likely that the cursor is being set again after >> you do it. Have you tried setting a breakpoint on [NSCursor set]? It's >> tricky to debug, because you don't want application switching to mess up the >> testing conditions, so you probably need to enable the breakpoint from the >> floating debugger window, and/or use carefully constructed debugger >> conditions. > > I checked this with a breakpoint. When a window become key the cursor is set. > So setting a custom cursor using this approach will never work. This also > explains why setting the cursor in initWithFrame: or awakeFromNib of a NSView > object also will not work.
Sounds like a job for delayed messaging. Change the code above to: - (void)windowDidBecomeKeyNotification:(NSNotification *)notification { if ([notification object] == [self window]) { NSPoint point = [[self window] mouseLocationOutsideOfEventStream]; NSRect frame = [self convertRectToBase:[self frame]]; BOOL condition = NSMouseInRect(point, frame, NO); if (condition) { [[NSCursor crosshairCursor] performSelector:@selector(set) withObject:nil afterDelay:0]; } } } That will send a -set message the next time through the event loop. -jcr _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com