C. Ocoa
C. Ocoa

Reputation: 107

Context Menu in NSBrowser

When right-clicking on an item in an NSBrowser view the selection won't change. Instead the item clicked on gets a frame and a context menu is opened. Selected item and right-clicked item are two different things.

In Finder (browser view), the operations in the context menu operate on the item the user right-clicks on, which is what I expect. If I do the same with a custom NSBrowser control, the operations are applied to the selected item instead.

I have attached an empty NSMenu to NSBrowser.menu to get the services menu. There  are NSBrowser's clickedRow/clickedColumn properties which yield valid values when queried from [NSMenuDelegate menuWillOpen], but this does not help me with the system-generated Services menu items.

How can I make the context menu operate on the right-clicked item?

EDIT 2017-10-29

I have subclassed NSBrowser for drag&drop support. This is how the context menu is added. It is an empty NSMenu, the Services menu is added automatically.

- (void) awakeFromNib
{
    NSMenu *m = [[[NSMenu alloc] init] autorelease];
    m.delegate = self;
    self.menu = m;
}

Upvotes: 1

Views: 143

Answers (0)

Related Questions