Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSCursor problem



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.