Reputation: 181
I need to show a menu on an NSTableView when user right clicks anywhere on the table row. Just like when we right click anywhere in the browser and menu shows up.
Upvotes: 1
Views: 371
Reputation: 74209
NSTableView
has Menu
property that can be assigned to your NSMenu
.
Of course all this can be done in Xcode's IB, but if you are doing this programmatically you need to construct a NSMenu, add the NSMenuItem(s) required and assign it to the NSTableView.
var menu = new NSMenu("A context menu")
{
Delegate = this
};
menu.AddItem(new NSMenuItem { Title = "StackOverflow" Action = SomeMenuAction });
aTableView.Menu = menu;
Upvotes: 1