Safari Developer Library

Developer

SafariExtensionMenu Class Reference

Options
Deployment Target:

On This Page

SafariExtensionMenu

Inheritance


  • SafariExtensionMenu

Conforms To


Not Applicable

Import Statement


Not Applicable Not Applicable

Availability


Available in Safari 5.1 and later.

The SafariExtensionMenu class represents menus.

  • identifier Property

    The unique identifier of the menu.

    Declaration

    JavaScript

    readonly attribute DOMString identifier

    Availability

    Available in Safari 5.1 and later.

  • menuItems Property

    The items in the menu.

    Declaration

    JavaScript

    readonly attribute array menuItems

    Availability

    Available in Safari 5.1 and later.

  • visible Property

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

    Declaration

    JavaScript

    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.

    Availability

    Available in Safari 5.1 and later.

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

    Declaration

    JavaScript

    SafariExtensionMenuItem appendMenuItem (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.

    Availability

    Available in Safari 5.1 and later.

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

    Declaration

    JavaScript

    SafariExtensionMenuItem appendSeparator (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.

    Availability

    Available in Safari 5.1 and later.

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

    Declaration

    JavaScript

    SafariExtensionMenuItem insertMenuItem (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.

    Availability

    Available in Safari 5.1 and later.

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

    Declaration

    JavaScript

    SafariExtensionMenuItem insertSeparator (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.

    Availability

    Available in Safari 5.1 and later.

  • Removes a menu item.

    Declaration

    JavaScript

    void removeMenuItem (in unsigned int index);

    Parameters

    index

    The index of the menu item being removed.

    Discussion

    Invalid indexes are ignored.

    Availability

    Available in Safari 5.1 and later.