Re: hey, Cocoa, don't touch that cursor
Re: hey, Cocoa, don't touch that cursor
- Subject: Re: hey, Cocoa, don't touch that cursor
- From: Matt Neuburg <email@hidden>
- Date: Wed, 30 Jan 2002 10:04:06 -0800
On Tue, 29 Jan 2002 22:14:01 -0800, email@hidden said:
>
> (Previously I had said:)
>
> My window redraws parts of itself periodically. If the user holds down
>
> the
>
> mouse on the window, I set the cursor (using push) and reset it to the
>
> arrow when the user release the mouse (using pop). But if the window
>
> happens to redraw itself while the mouse is being held down, the cursor
>
> is
>
> (prematurely) reset to the arrow at that moment
>
>
As I recall, there is a private method which gets called whenever a
>
window updates (in the AppKit sense of "update", not necessarily a view
>
redisplay). That private method calculates the "correct" cursor based
>
upon the cursor rects in the window and sets it absolutely (wiping out
>
whatever cursor stack may be in place)
>
A better fix would probably be to do what you are doing now using
>
push/pop using cursor rects instead, if you can. Change the cursor for
>
your view, or whatever subset of your view, to properly be the cursor
>
you want. This way if the AppKit decides to recalculate what the cursor
>
is, which it does from time to time, it will get the correct answer.
>
Another possible fix would be not to return to the top of the run loop
>
until you are done with your drag and have popped the cursor.
Thanks. This was a very helpful answer and makes sense. I still see this as
a bug; if I say the cursor is the Hand, it should stay the Hand until I say
otherwise. In the end I used the second suggested fix, copying the example
in the docs for mouse events: when the mouse goes down, I short-circuit the
event loop and handle mouse-dragged and mouse-up without returning to the
main loop. This solves the problem adequately. m.
--
matt neuburg, phd = email@hidden,
http://www.tidbits.com/matt
pantes gar anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart.
http://www.tidbits.com/