Safari Reference Library Apple Developer
Search

SafariExtensionToolbarItem Class Reference

Inherits from
Technology area
Safari Extensions
Availability
Available in Safari 5.0 and later.

Overview

Instances of the SafariExtensionToolbarItem represent items that your extension adds to the Safari toolbar. Users can select which toolbar items are shown by selecting Customize Toolbar in the same way they can add and remove toolbar items that are provided by Safari.

Tasks

Setting Up the Appearance

Handling Click Events

Properties

badge

The current badge number.

attribute long badge
Discussion

The default value is 0, which hides the badge. If you set a value that is too long, the beginning and end of the value will be shown with an ellipsis in the middle.

Setting a value of NaN or Infinity is treated as 0. Non-integer values are rounded to the nearest integer.

Availability

browserWindow

The containing browser window.

readonly attribute SafariBrowserWindow browserWindow
Availability

command

The command identifier that the toolbar item sends when it is clicked.

attribute DOMString command
Discussion

This attribute is optional; its value defaults to the value of identifier.

Setting a value of null, undefined, or the empty string has no effect.

Availability

disabled

A Boolean value that indicates whether the toolbar item is disabled.

attribute boolean disabled
Discussion

The default value is false. Nothing happens when the user tries to interact with a toolbar item that is disabled.

Availability

identifier

The unique identifier of the toolbar item.

readonly attribute DOMString identifier
Discussion

This attribute is required.

Availability

image

The current image URL.

attribute DOMString image
Discussion

This attribute can be changed to the URL of an image in the extension bundle. Setting a value of null, undefined, or the empty string has no effect.

Availability

label

The label of the toolbar item, as shown in the toolbar’s overflow menu.

attribute DOMString label
Discussion

This attribute is required. Setting a value of null, undefined, or the empty string has no effect.

Availability

paletteLabel

The label of the toolbar item, as shown in the Customize palette.

readonly attribute DOMString paletteLabel
Discussion

This attribute is optional; its value defaults to the value of label.

Availability

toolTip

The tooltip (help tag) of the toolbar item.

attribute DOMString toolTip
Discussion

This attribute is optional; its value defaults to the value of label.

Setting a value of null, undefined, or the empty string has no effect.

Availability

Methods

validate

Dispatches a validate event for this toolbar item.

void validate (void);

Discussion

You should call this method after a state change occurs that is relevant to your validate-event listeners. Safari also automatically sends validate events for many common browser actions, such as switching tabs and navigating to a new page.

Availability
  • Available in Safari 5.0 and later.



Last updated: 2010-07-13

Did this document help you? Yes It's good, but... Not helpful...