Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Bug-Creator

macrumors 68000
Original poster
May 30, 2011
1,864
4,786
Germany
<- Objective-C/Cocoa newbie here

What I got is a class deviated from NSView which implements "- (void) mouseDown:(NSEvent *)event" and "- (void) mouseMoved:(NSEvent *)event". Both work pretty much expected but want those events (and others) to go through other classes depending on which tool was set by the user.

Found "nextResponder" and tried to set that to one of my tool classes (based on NSResponder) but solar no luck.

Ideal solution would be for the tool class to receive all events first and either refer them back to NSView based class or "eat" them.
 
Well found a solution and in case someone hits here via Google:

self.nextResponder = ehandler; does send messages not defined in NSVIew (self) to ehandler (the tool)

It gets a bit more complicated for events that I might want to use NSView or "eaten" by the tool.
- (void) mouseDown:(NSEvent *)event
{
[ehandler mouseDown:event];
}

Does work, but I have no way of telling wether the event should be "eaten" cos that function return void.

a) find a way to invalidate an NSEvent
b) implement eventhandling in the tool classes independently of functions inherited from NSResponder
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.