Re: Custom-view cursor changing
Re: Custom-view cursor changing
- Subject: Re: Custom-view cursor changing
- From: John Stiles <email@hidden>
- Date: Tue, 27 Nov 2007 14:05:13 -0800
Heh, of course, after posting I found a workaround. In -mouseDown: you
can do:
[[self window] disableCursorRects];
And in -mouseUp:
[[self window] enableCursorRects];
[[self window] resetCursorRects];
And this resolves the issue.
There are two things I'm still not sure of:
- Is -resetCursorRects necessary here? Or is the re-enable enough to
take care of everything?
- Is this actually a good solution? It seems to work fine but I am not
really sure if it's the best approach.
John Stiles wrote:
I have a custom NSView subclass which overrides -mouseDown:,
-mouseDragged: and -mouseUp:. In response to dragging, the control can
resize itself and some ancillary views in the window (within a limited
range, of course). Conceptually it's a lot like a split view.
I am trying to change the cursor when the drag starts by calling
[myCursor push] inside -mouseDown:, and restoring it via [NSCursor
pop] inside -mouseUp:. I'm finding that if I just click and release,
this works great.
However, dragging does not work as expected. When -mouseDragged: is
called and I change various views' bounds (via setFrame), suddenly the
cursor pops back to being an arrow cursor.
This appears to be happening because some view I'm using is posting a
notification saying that it needs to reset its cursor rects. When I
set a breakpoint on -[NSCursor set], I get this:
#0 0x911034d6 in -[NSCursor set]
#1 0x913dbafd in -[NSWindow resetCursorRects]
#2 0x91108315 in _handleInvalidCursorRectsNote
#3 0x90f039e2 in __CFRunLoopDoObservers
#4 0x90f04d45 in CFRunLoopRunSpecific
#5 0x90f05d38 in CFRunLoopRunInMode
#6 0x92cf28a4 in RunCurrentEventLoopInMode
#7 0x92cf25f6 in ReceiveNextEventCommon
#8 0x92cf2531 in BlockUntilNextEventMatchingListInMode
#9 0x9107cd5b in _DPSNextEvent
#10 0x9107c6a0 in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:]
#11 0x910756d1 in -[NSApplication run]
I don't know exactly how to solve this, though. I'm definitely not
posting anything like this, and the other views involved are all
standard OS X NSViews (e.g. in this case there are NSOutlineViews,
NSButtons and NSTextViews… not exactly rocket science).
Has anyone seen this before and maybe found a workaround? Maybe I need
to do something to enable "live-resize mode" in my mouseDown/mouseUp
methods?
I notice that I'm not alone—Xcode has the same problem when dragging
its splitter in the main project window.
_______________________________________________
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
_______________________________________________
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