Safari Developer Library

Developer

SafariExtensionMenuItem Class Reference

Options
Deployment Target:

On This Page

SafariExtensionMenuItem

The SafariExtensionMenuItem class represents items in a menu.

Inheritance


Conforms To


Not Applicable

Import Statement


Not Applicable Not Applicable

Availability


Available in Safari 5.1 and later.
  • command Property

    The command identifier that the menu item sends when activated.

    Declaration

    JavaScript

    attribute DOMString command

    Discussion

    If the submenu property is null, setting the value of this property to null, undefined, or the empty string has no effect.

    If the submenu property is defined, validate events are sent using the value of this property; if this property is blank, events are sent using the menu item’s identifier.

    Changes made to the command property take effect immediately, regardless of visibility.

    Availability

    Available in Safari 5.1 and later.

  • identifier Property

    The unique identifier of the menu item.

    Declaration

    JavaScript

    readonly attribute DOMString identifier

    Availability

    Available in Safari 5.1 and later.

  • separator Property

    A Boolean value that indicates whether the menu item is a separator.

    Declaration

    JavaScript

    readonly attribute boolean separator

    Discussion

    This attribute is optional; the default value is false.

    Availability

    Available in Safari 5.1 and later.

  • title Property

    The title displayed in the menu.

    Declaration

    JavaScript

    attribute DOMString title

    Discussion

    If the separator property is true, the value of this property is ignored.

    Setting this property to the empty string, null, or undefined has no effect.

    Availability

    Available in Safari 5.1 and later.

  • image Property

    The URL of the image shown next to the menu item.

    Declaration

    JavaScript

    attribute DOMString image

    Discussion

    This attribute can be changed to the URL of an image in the extension bundle. Images larger than 16 x 16 pixels are scaled down to fit. Supported URL schemes are safari-extension, http, and https.

    On Windows, if the menu item is checked, the icon is not displayed.

    To support HiDPI, provide an image of the appropriate resolution at the same location, with the suffix @2x after its name. For example some/path/image-name@2x.png and some/path/image-name.png provide the same image at high resolution and standard resolution, respectively.

    Availability

    Available in Safari 5.1 and later.

  • submenu Property

    The submenu displayed by this menu item.

    Declaration

    JavaScript

    attribute SafariExtensionMenu submenu

    Discussion

    If the separator property is true, the value of this property is ignored.

    If the value of this property is null or undefined, no submenu is displayed.

    If the value is a menu that is already being displayed, no submenu is displayed and this menu item’s command is dispatched. This prevents recursive menus.

    If the menu item is visible, changes to this property are not reflected until the next time the menu item is displayed.

    The behavior if the submenu is removed using the SafariExtension removeMenu method while the menu item is visible is undefined.

    Availability

    Available in Safari 5.1 and later.

  • visible Property

    A Boolean value that indicates whether the menu item is visible.

    Declaration

    JavaScript

    readonly attribute boolean visible

    Discussion

    Changes made to the menu item while it is visible are not reflected until the next time it presented, except for changes made to the command property, which take effect immediately.

    Availability

    Available in Safari 5.1 and later.

  • disabled Property

    A Boolean value that indicates whether a menu item is disabled.

    Declaration

    JavaScript

    attribute boolean disabled

    Discussion

    This property is optional; the default value is false.

    Availability

    Available in Safari 5.1 and later.

  • checkedState Property

    The state of the menu item.

    Declaration

    JavaScript

    attribute short checkedState

    Discussion

    For possible values, see Menu Item States. Any other value you set is ignored.

    This property is ignored for separator items.

    This property is optional; the default state is unchecked.

    Availability

    Available in Safari 5.1 and later.

Constants

  • The state of a menu item, indicated by a small icon displayed next to the title.

    Declaration

    Constants

    • CHECKED

      CHECKED

      Checked state.

      Available in Safari 5.1 and later.

    • MIXED

      MIXED

      Mixed state.

      On Windows, this is treated as CHECKED.

      Available in Safari 5.1 and later.

    • UNCHECKED

      UNCHECKED

      Unchecked state.

      Available in Safari 5.1 and later.