Search code examples
cocoacontextmenuright-clickfirst-responder

Cocoa Responder Chain and Context Menu Click


I have a view-based NSTableView populated custom NSTabelCellView subclass, which are the lowest objects in the view hierarchy (no subviews). I overrode the mouseDown: method to intercept mouse clicks. This fine when user left-click the cell view, however, when they right click the cell view this method somehow never gets called, and somehow the menu associated with the table view still shows up, even though the cell view is suppose to be the first object to respond. Does anyone know why this is? How can I intercept right clicks in a view?


Solution

  • There are different groups of methods for each of the three main mouse buttons.

    Anyway, you probably don't want to implement this at such a low level. If the context menu is the same throughout the table view, just set its menu. If you want it to differ for each cell, you might try setting the cell view's menu.