I'm trying to provide a contextual menu to a table view that I have in my standard Cocoa application. Ideally, this will allow those with two-button mice or those with lightning-quick reflexes to quickly access some options based on the item selected in the list.
However, I'm having an annoying problem: when you right-click directly on an item in the NSTableView, the item under the mouse isn't automatically selected! Because how my actions are created, they rely on the selected item in the NSTableView, so right-clicking in the table view and then selecting an action will probably not (in most cases) result in the action being applied to the desired item. This negates the usefulness of the contextual menus to a great extent.
What's the easiest way to modify the mouse event so that a control-click on this NSTableView will first select the item and THEN bring up the contextual menu? (I'm even interested in "workarounds" where you would get the mouse position at the time of the control-click, and then my program would calculate which item should be selected, select it, and then bring up the menu.)
However, I'm having an annoying problem: when you right-click directly on an item in the NSTableView, the item under the mouse isn't automatically selected! Because how my actions are created, they rely on the selected item in the NSTableView, so right-clicking in the table view and then selecting an action will probably not (in most cases) result in the action being applied to the desired item. This negates the usefulness of the contextual menus to a great extent.
What's the easiest way to modify the mouse event so that a control-click on this NSTableView will first select the item and THEN bring up the contextual menu? (I'm even interested in "workarounds" where you would get the mouse position at the time of the control-click, and then my program would calculate which item should be selected, select it, and then bring up the menu.)