Non-rectangular cursor tracking regions
Non-rectangular cursor tracking regions
- Subject: Non-rectangular cursor tracking regions
- From: Ron Aldrich <email@hidden>
- Date: Thu, 19 Apr 2007 16:21:58 -0700
Folks,
Has anyone come up with a reasonable way to allow cursor changes to
be based on non-rectangular regions?
Digging through the archives, the best advice I could find was as
follows:
o Add multiple tracking rects that more or less "scan convert" your
circle into a set of rectangular areas.
o Use a single rect and live with it.
o Try to use [NSCursor pushCursor] / [NSCursor popCursor], and
struggle with the various issues raised earlier on the list about
the problems with this approach and its basic lack of support in
the Kit.
Of the three, I'd recommend choice #1; you may not need to use very
many rectangles to give the user the feel that the circle is the
"live" area, depending on how big the circle is. I'd just write a
utility method (perhaps a category, to harken to other current
threads ;->) that does this for you in a general way.
None of which seem like particularly good solutions.
The first would generate a tremendous number of tracking rectangles.
Reducing the number of rectangles would reduce the accuracy of the
cursor, leading to unexpected behavior.
The second doesn't give enough user feedback - everything becomes
unexpected behavior (sounds like a Windows app).
The third looks to be fraught with terror.
One possibility I'm toying with is to use a single rect, and change
it based on the mouse's current location - however, I found a thread
that indicated that this probably won't work either, as the cursor
won't be updated until after the mouse moves again - I'm hoping that
setting the cursor would solve that problem.
Would calling the following on mouse moved events be advisable?
- (void) setCursor: (NSCursor*) inCursor
forView: (NSView*) inView
{
[inView discardCursorRects];
[inView addCursorRect: [inView visibleRect]
cursor: inCursor];
[inCursor set];
}
Thanks for your time,
Ron Aldrich
Software Architects, Inc.
_______________________________________________
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