0
votes

I have a NSTableView in which cells are NSTextFields.

I assign a menu to the text fields.

Menus are supposed to open when I right click on a cell.

I have this secondary click equal to click on the right side turned on.

enter image description here

I right click on the cell, I see macOS context menu below:

enter image description here

I Control Click on the cell, I see the NSMenu I have created

enter image description here

That is what I want.

If I disable the secondary click at the settings, when I right click, the cell enters edit mode and when I control click, the NSMenu I have created shows.

Questions:

  1. Isn't Control Click meant to be the same as the right click when the secondary click on the right side is enabled?
  2. Why is macOS not recognizing that?
  3. Why in the hell am I seeing macOS context menu there?
1

1 Answers

3
votes

Control-click and right-click are two separate events. That is, an app can distinguish them.

The default behavior for Cocoa views is for both Control-click and right-click to open the contextual menu. So, in that sense, they almost always have the same effect.

I'm not sure why you're seeing two different menus depending on which kind of click you use. My guess is that they are targeting two different views: the table row view vs. the table cell view vs. a view within the table cell view (if the cell view has subviews). We would need to have more details about exactly how you've set things up to know.

Typically, you should set a menu on the table view, itself, and have its actions operate on the table's clickedRow.