Class

SafariExtensionContextMenu

Instances of the SafariExtensionContextMenu class represent a contextual menu that is populated by the extension. Safari displays the contents of this menu as part of its contextual menu.

Overview

Each time a contextual menu is about to be displayed, Safari creates a new menu, populated with the default menu items from your extension’s Info.plist file. Next, a SafariExtensionContextMenuEvent event is sent, and its listeners add menu items to the menu. Then a SafariExtensionContextMenuItemValidateEvent is sent for each menu item, and its listeners have the opportunity to prevent items in the context menu from being displayed by marking them as disabled.

Your extension has access only to context menu items that it has added; there is no way to change or count menu items from Safari or other extensions. Therefore, it is important to limit the menu items that your extension adds to a reasonable number, to avoid displaying an unusably long contextual menu.

Topics

Adding Menu Items

appendContextMenuItem

Appends a menu item to the contextual menu.

insertContextMenuItem

Inserts a menu item at a specific index in the contextual menu.

Accessing Menu Items

contextMenuItems

Returns a list of the context menu items from this extension.