Re: why mouseMoved doesn't work...
Re: why mouseMoved doesn't work...
- Subject: Re: why mouseMoved doesn't work...
- From: Don Yacktman <email@hidden>
- Date: Thu, 10 Oct 2002 15:38:08 -0600
On Thursday, October 10, 2002, at 01:55 PM, John MacDonnell wrote:
Hi folks I have a problem connected with the use of mouseMoved events...
I set a tracking area and it works great with:
-(void)mouseEntered:(NSEvent*)event
-(void)mouseExited:(NSEvent*)event
But the:
- (void)mouseMoved:(NSEvent *)theEvent
it doesn't work... the method seems not even to be called... I miss
something somewhere I guess. Can you tell me what I do wrong here?
The answer to this question is found in chapter 15 of Cocoa programming.
The window containing the view that wants to receive this event needs to
be told that it has a view that wants mouse moved events. See the
NSWindow docs for more info. Since this event comes in fast and
furious, it is off by default. Note that the view's window ALSO has to
be the key window, or the event won't come in!
Sometimes it is a better alternative to poll for the mouse position on a
regular basis; it depends upon what you're doing. For example, if
you're doing a view with eyes that follow the mouse cursor, you can't
force your window to always be key, and you don't really need EVERY
mouse moved event anyway. So animate it at a rate of, say, 24
frames/sec and get the mouse's current position at the start of each
frame render. It actually becomes a lot more efficient and won't bog
down the CPU as much every time you move the mouse. Sometimes mouse
move events are really what you want, but I find those situations pretty
rare.
--
Later,
Don Yacktman
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.