Founding sponsorYour name here

The menu at the pointer is a context menu — right-click (or click) the folder to toggle it

Context Menu

/ NSMenu · View.contextMenu(menuItems:) /

also called contextual menu, right-click menu, shortcut menu

A context menu exposes actions relevant to the object under the pointer and opens from a secondary click or Control-click. It appears near that click and is made from standard menu items, separators, keyboard equivalents, and submenus. A dropdown menu has a visible control that opens it with a primary click, while a context menu is invoked directly from the content.

If you called it…

the menu that appears when you right clickcontrol click options for the thing under the pointersmall action menu beside the selected itemcopy rename delete menu under the mousemenu that opens from a secondary click

…you meant a context menu.

Anatomy — every part, named

  1. 1
    Selection highlightNSMenuItem

    “The blue bar behind the option under the pointer” is the menu item's selection highlight.

  2. 2
    Separator itemNSMenuItem.separator()

    “The little line between groups of right-click options” is a separator item.

  3. 3
    Key equivalentNSMenuItem.keyEquivalent

    “The keyboard shortcut text on the right” is the item's key equivalent.

  4. 4
    Submenu indicatorNSMenuItem.submenu

    “The sideways arrow that opens more options” is the submenu indicator.

Prompt — paste into your agent

Add a Context Menu using NSMenu on the target NSView (SwiftUI: View.contextMenu), opened by right-click or Control-click at the item under the pointer. Populate it with actions specific to that item; do not turn it into a primary-click dropdown anchored to a button.

Debug prompt — when it misbehaves

Paste this, then describe what you’re seeing — it hands your agent the classic failure modes to rule out first.

Debug my macOS context menu (NSMenu, menu(for:), SwiftUI .contextMenu). Rule out: the menu built once and gone stale — implement menuNeedsUpdate/menuWillOpen; items greyed out because their target is nil and nothing in the responder chain implements the action; right-click, control-click and two-finger tap taking different code paths; a SwiftUI .contextMenu swallowing plain clicks on the row. The symptom:

In code

The exact names this thing goes by in code — each row is one framework’s word for it. Use the row that matches your project (or paste it into your prompt).

AppKitNSMenu
SwiftUIView.contextMenu(menuItems:)
AppKitNSView.menuthe contextual menu associated with a view
AppKitNSMenuItem

See also

Search

Describe the UI element you're thinking of