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

NSCursor problem


  • Subject: NSCursor problem
  • From: Sarah Dumoulin <email@hidden>
  • Date: Thu, 30 Nov 2006 13:14:39 -0500

Hello,

I am trying to change the cursor in an opengl view in response to a call from a library. In my NSOpenGLView I have the following functions defined:

- (void) setArrowCursor {
	currentCursor = crossCursor;
	[self resetCursorRects];
	[[self window] invalidateCursorRectsForView:self];
}

or

- (void) setPointerCursor {
	currentCursor = pointerCursor;
 	[self resetCursorRects];
	[[self window] invalidateCursorRectsForView:self];
}

- (void) resetCursorRects {
	[super resetCursorRects];
	if (currentCursor != nil && currentCursor != [NSCursor arrowCursor]) {
		[self addCursorRect:[self visibleRect] cursor: pointerCursor];
	} else if (currentCursor != nil) {
		[self addCursorRect:[self visibleRect] cursor:arrowCursor];
	}
}

My code gets to the setCursor, and resetCursorRects is called, but doesn't work as expected. I realise that the calls to resetCursorRects in the setCursor functions should be unecessary, but in practice invalidateCursorRectsForView only causes resetCursorRects to be called the very first time I change the cursor. On subsequent attempts to change the cursor invalidateCursorRects does not cause resetCursorRects to be called. However, this doesn't get me anywhere, as if I call resetCursorRects myself it doesn't seem to actually do anything.

If I mouse over the area where the cursor should change the following behaviour happens:

1) On the first mouse-in the cursor is changed to the pointerCursor, and displays correctly
2) On subsequent mouse-outs or ins the cursor does not change. However, if I tab so that the window is hidden, and then tab back so that it is back in focus, the cursor is changed (this tabbing back and forth kicks resetCursorRects automatically, performing the required change).


The event loop seems to be functioning OK, as I can still access menu commands and they work as expected (but the cursor remains in the wrong state).

I've tried calling makeKeyWindow/makeKeyAndOrderFront, I've tried using setFrame to try to force the window to call resetCursorRects, and I've tried calling [window display], but none of these worked. invalidateCursorRectsForView is supposed to call resetCursorRects immediately if the view is key. I'm not sure why the view would no longer be key after I have simply moved the mouse back and forth over (but still inside) the window, and I'm not sure how to force this particular view to be key (as opposed to the window), or even if that makes sense as a concept.

Does anybody have any idea what I'm doing wrong here?

Thanks,

Sarah

--
Sarah Dumoulin										email@hidden
Communications Research Centre						www.crc.ca
Ottawa, ON
Phone: 613 990-5242
Fax: 613 998-9648



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: NSCursor problem
      • From: "Sean McBride" <email@hidden>
  • Prev by Date: Re: Bindings: changing model changes some views but not others (NSTableColumn)
  • Next by Date: Re: Problems with NSArrayController and keyPath Operator
  • Previous by thread: Re: changing [NSWindow isOpaque] in subclass
  • Next by thread: Re: NSCursor problem
  • Index(es):
    • Date
    • Thread