You can use the table views clickedRow
property/method to determine on which row the click was placed. Next get from your data source the object for the clicked row and that is it.
How to find out which cell was right clicked (despite a differing selection)
-
04-07-2023 - |
Question
I am using an NSTableView
which is connected to a NSMenu
in IB.
Now I can right click a selected cell and choose the context menu for the selected item.
This is all fine, however, the TableView can show context menu for items which are not selected:
So now the action applies to the selected item in the list, rather than item that was actually right-clicked: I want to open 6
but eventually 1
is opened in the browser.
This is how I handle the click Event:
- (IBAction)openInBrowserClicked:(id)sender {
Issue *i = self.issuesController.selectedObjects.lastObject;
[[NSWorkspace sharedWorkspace] openURL:i.URL];
}
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow