How do I populate an NSMenuToolbarItem with Continuity Camera menu items?

21 hours ago 3
ARTICLE AD BOX

In Apple apps like Mail and Notes, some NSMenuToolbarItem menus (e.g. Photo Browser, Media) include Continuity Camera actions under an Import from iPhone or iPad section (typically after a separator).

I am building a macOS AppKit app that uses NSTextView as the primary editor, which is relevant here.

I can get Continuity Camera menu items to appear automatically in both:

the main menu (by adding Import from Device in Interface Builder) a contextual menu (works “for free”)

I believe this happens because NSTextView already implements the required responder methods, which is why I do not need to override:

readSelection(from:) validRequestor(forSendType:returnType:)

What does not work

I cannot get the same Continuity Camera menu items to populate when the menu is used inside an NSMenuToolbarItem.

I build the menu in Interface Builder, add an Import from Device menu item, expose it via an @IBOutlet, then assign it to the toolbar item:

func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? { let item = NSMenuToolbarItem(itemIdentifier: itemIdentifier) item.menu = storyboardMenu return item }

What happens

The toolbar menu only shows a single static item:

Import From Device

It does not expand into Continuity Camera actions, unlike the main menu and contextual menu.


What I’m trying to achieve

I want the menu toolbar item to behave the same way as the main menu and contextual menu and to be co-ordinated with the active NSTextView, so that Continuity Camera actions are populated automatically.


Question

How do I correctly populate an NSMenuToolbarItem with Continuity Camera menu items when working with NSTextView?

Is there an additional requirement for toolbar menus — such as explicit responder-chain wiring, menu validation, or associating the toolbar item with a specific NSView — that differs from how main menus and contextual menus work?

Read Entire Article