PDA

View Full Version : rightMouseDown not working?


AnotherJake
2004.10.20, 03:17 PM
I'm at a loss to explain this. I get left mouse down and up and I get right mouse up, but no right mouse down? Does anybody have any ideas why this might be happening? Here's the code with NSLogs put in for diagnostics.
//---------------------------------------------------------------------------
- (void)mouseDown:(NSEvent *)theEvent
{
NSLog( @"left mouse down" );
input.leftMouse = YES;
}

//---------------------------------------------------------------------------
- (void)mouseUp:(NSEvent *)theEvent
{
NSLog( @"left mouse up" );
input.leftMouse = NO;
}

//---------------------------------------------------------------------------
- (void)rightMouseDown:(NSEvent *)theEvent
{
NSLog( @"right mouse down" );
input.rightMouse = YES;
}

//---------------------------------------------------------------------------
- (void)rightMouseUp:(NSEvent *)theEvent
{
NSLog( @"right mouse up" );
input.rightMouse = NO;
}

AnotherJake
2004.10.20, 03:39 PM
That's weird, I've been working on this for hours and so I finally gave up and posted. Of course, right after that I had a stroke of luck with it and discovered that the rightMouseDown events are sent to the view under the mouse even though I specifically say that it does not accept first responder. This still doesn't make sense to me but at least I found a work-around. I also tried ignoresMouseEvents to prevent it from going to the view, but that doesn't work either. I'll get by with it for now unless somebody knows a better way. It would be nice to prevent the rightMouseDown events from going to the view instead of my input handler where they belong.

arekkusu
2004.10.20, 03:40 PM
What object is this in?

If need be, you can subclass NSApp with:

- (void) sendEvent:(NSEvent*)event {
NSLog(@"event %@", event);
[super sendEvent: event];
}

and test the event type and either process it right there or forward it to your object.

AnotherJake
2004.10.20, 03:55 PM
It's in my window controller, but I've always had it in my view so that's why I've never had this problem before. I'm thinking about moving it back to the view now with this crap happening. The problem is that I've been planning on doing a multi-view for this program (it's a level editor) and it seems to make more sense that it be in the window controller.

I already have NSApplication overridden to pass all the keyUp events along, so that definitely wouldn't be a problem, and I was just considering that myself. I might still do that.