Re: Unresponsive mouseMoved method
Re: Unresponsive mouseMoved method
- Subject: Re: Unresponsive mouseMoved method
- From: Bob Smith <email@hidden>
- Date: Wed, 28 Mar 2007 17:49:29 -0700
The window delegate cannot handle mouse events because those do not
follow the responder chain as do actions; mouse events are sent by
the window to the view in which the event occurred, and nowhere
else. You have done the correct thing by extending your view class,
and I don't see anything wrong with your solution.
Hope this helps!
Bob S.
On Mar 28, 2007, at 5:29 PM, Steve Bryan wrote:
I'm trying to discover why my mouseMoved method does not get
called. I've
declared it for a controller class which is the delegate for the
window. In
its awakeFromNib method I have the calls:
[mWindow setAcceptsMouseMovedEvents: YES];
[mWindow setDelegate: self];
I also have mouseMoved defined for this controller class:
- (void)mouseMoved: (NSEvent*)theEvent
{
NSLog(@"mouseMoved");
}
There is other code in there but it never gets called (ie repeated
output of
"mouseMoved" in the log). If I override it in an NSView subclass it
does get
called. But there are several panes and only one will be the next
responder
in the chain.
While composing this query a solution has been found but it seems a
bit
convoluted. I already used a category to extend NSView so I just
added this
to the category:
- (void) mouseMoved: (NSEvent*)theEvent
{
[[[self window] delegate] performSelector: @selector(mouseMoved:)
withObject: theEvent];
}
Exactly one of the subviews will be active and it nicely transfers
the call
over to the delegated controller class so all is well. I'm still
wondering
why the original "wiring" did not work and if there is some
possible defect
in my tricky solution.
p.s. My controller class is a subclass of NSReponder
_______________________________________________
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
_______________________________________________
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