2

I'm trying to get a NSOutlineView to accept secondary clicks, but can't seem to figure it out. I've tried changing secondary clicks from two fingers, to right corner and left corner on the trackpad, and still I don't get any respons in my outline view on mousedown events. can anyone help me?

UPDATE:

If i use this the secondary click is logged, but it still doesnt show up in the rightMouseDown: function.

[NSEvent addLocalMonitorForEventsMatchingMask:NSRightMouseDownMask handler:^(NSEvent* event) {
    NSLog(@"%@", event);
    return (NSEvent *)event;

}];

UPDATE:

I still don't know how to solve this. My NSCollectionView responds to rightMouseUp but not rightMouseDown. How come?

tnx

2 Answers2

0

The apple documentation specifically talks about rightMouseDown being handled in higher up in the responder chain (for context menus) and it specifically is not passed down into one's subclass. The documentation talks about overriding acceptsFirstResponder, but I was not able to get that to work either.

So while I couldn't get the rightMouseDown event to fire, I was able to modify your code to fake it. Instead of logging the event, I have it call my rightMouseDown event handler instead.

[NSEvent addLocalMonitorForEventsMatchingMask:NSRightMouseDownMask handler:^(NSEvent* event) {
        [self rightMouseDown:event];
        return (NSEvent *)event;
    }];

Hopefully, someone will be able to shine some better light on the issue than this, but at least this is a start.

Zack
  • 1,201
  • 8
  • 21
0

Having similar issues when overriding mouseDown: I needed to call rightMouseDown: from mouseDown to have the same behavior in both cases. This stopped working in Mavericks.

Instead it seems it is better to change the event type to a rightmousedown click when you need this to happen. Maybe this will help you:

- (void)mouseDown:(NSEvent *)event;
{
    [event setValue:@(NSRightMouseDown) forKey:@"type"];
    [self rightMouseDown:event];
}