• 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: Document Cursor
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Document Cursor


  • Subject: Re: Document Cursor
  • From: "John C. Randolph" <email@hidden>
  • Date: Wed, 25 Aug 2010 12:41:46 -0700

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 (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: Document Cursor
      • From: Richard Somers <email@hidden>
References: 
 >Document Cursor (From: Richard Somers <email@hidden>)
 >Re: Document Cursor (From: "John C. Randolph" <email@hidden>)
 >Re: Document Cursor (From: Richard Somers <email@hidden>)
 >Re: Document Cursor (From: Quincey Morris <email@hidden>)
 >Re: Document Cursor (From: Richard Somers <email@hidden>)

  • Prev by Date: Re:UIViewController and splash screen orientation issue on iPad
  • Next by Date: Help with bindings in a custom view
  • Previous by thread: Re: Document Cursor
  • Next by thread: Re: Document Cursor
  • Index(es):
    • Date
    • Thread