Safari Developer Library

Developer

SafariExtensionMenu Class Reference

Options
Deployment Target:

On This Page

SafariExtensionMenu

The SafariExtensionMenu class represents menus.

  • identifier Property

    The unique identifier of the menu.

    Declaration

    readonly attribute DOMString identifier

  • menuItems Property

    The items in the menu.

    Declaration

    readonly attribute array menuItems

  • visible Property

    A Boolean value that indicates whether the menu is currently visible to the user.

    Declaration

    readonly attribute boolean visible

    Discussion

    Changes made to the menu while it is visible to the user are not reflected until the next time it is shown. If the user selects a menu item that was removed after the menu became visible, the menu item’s command is not sent.

  • Creates a menu item and appends it to the menu.

    Declaration

    SafariExtensionMenuItemappendMenuItem (in DOMString identifier, in DOMString title, in DOMString command);

    Parameters

    identifier

    The unique identifier of the menu item.

    title

    The title of the menu item.

    command

    The command identifier to send when the menu item is activated. This parameter is optional; the default value is the menu item’s identifier.

    Return Value

    The menu item that was appended.

    Discussion

    If a menu item with the same identifier already exists, it is removed from before appending the menu item.

  • Creates a separator menu item and appends it to the menu.

    Declaration

    SafariExtensionMenuItemappendSeparator (in DOMString identifier);

    Parameters

    identifier

    The unique identifier of the menu item.

    Return Value

    The menu item that was appended.

    Discussion

    If a menu item with the same identifier already exists, it is removed from before appending the separator.

  • Creates a menu item and inserts it in the menu at the given index.

    Declaration

    SafariExtensionMenuIteminsertMenuItem (in unsigned int index, in DOMString identifier, in DOMString title, in DOMString command);

    Parameters

    index

    The index at which the menu item is being inserted.

    identifier

    The unique identifier of the menu item being inserted.

    title

    The title of the menu item.

    command

    The command identifier to send when the menu item is activated. This parameter is optional; the default value is the menu item’s identifier.

    Return Value

    The menu item that was inserted.

    Discussion

    If a menu item with the same identifier already exists, it is removed from before inserting the menu item.

    If the value of index is NaN, Infinity, a negative number, or a number greater than the number of items in the menu, the menu item is appended at the end of the menu.

  • Creates a separator menu item and inserts it in the menu at the given index.

    Declaration

    SafariExtensionMenuIteminsertSeparator (in unsigned int index, in DOMString identifier);

    Parameters

    index

    The index at which the menu item is being inserted.

    identifier

    The unique identifier of the menu item being inserted.

    Return Value

    The menu item that was inserted.

    Discussion

    If a menu item with the same identifier already exists, it is removed from before inserting the separator.

    If the value of index is NaN, Infinity, a negative number, or a number greater than the number of items in the menu, the separator is appended at the end of the menu.

  • Removes a menu item.

    Declaration

    voidremoveMenuItem (in unsigned int index);

    Parameters

    index

    The index of the menu item being removed.

    Discussion

    Invalid indexes are ignored.