Visit Mozilla.org

XUL:toolbar

From MDC

« XUL Reference home    [ Examples | Attributes | Properties | Methods | Related ]

A container which typically contains a row of buttons. It is a type of box that defaults to horizontal orientation. It can be collapsed with a grippy when the toolbar is placed inside a toolbox. The toolbar should always have an id attribute. Firefox supports toolbar customization, whereas the Mozilla browser does not.

More information is available in the XUL tutorial.

Attributes
currentset, customindex, customizable, defaultset, grippyhidden, grippytooltiptext, mode, toolbarname
Properties
accessibleType, currentSet, firstPermanentChild, lastPermanentChild, toolbarName
Methods
insertItem

[edit] Examples

Image:XUL_ref_toolbar.png
<toolbox>
  <toolbar id="nav-toolbar">
    <toolbarbutton id="nav-users"  accesskey="U" label="Users"/>
    <toolbarbutton id="nav-groups" accesskey="p" label="Groups"/>
    <toolbarbutton id="nav-events" accesskey="E" label="Events" disabled="true"/>
  </toolbar>
</toolbox>

[edit] Attributes

Inherited from XUL element
align, allowevents, allownegativeassertions, class, coalesceduplicatearcs, collapsed, container, containment, context, contextmenu, datasources, dir, empty, equalsize, flags, flex, height, hidden, id, insertafter, insertbefore, left, maxheight, maxwidth, menu, minheight, minwidth, mousethrough, observes, ordinal, orient, pack, persist, popup, position, preference-editable, querytype, ref, removeelement, sortDirection, sortResource, sortResource2, statustext, style, template, tooltip, tooltiptext, top, uri, wait-cursor, width

currentset
Firefox only
Type: comma-separated string
The current set of displayed items on the toolbar. This will be modified when the user customizes the toolbar. The value of this attribute should be a comma-separated list of item IDs from the toolbarpalette or, additionally, any of the following strings: "separator", "spring", "spacer".

customindex
Firefox only
Type: integer
This value is the index of the toolbar in the list of the custom toolbars. The value is updated automatically by the toolbar customization dialog.

customizable
Firefox only
Type: boolean
Set this attribute to true on toolbars that can be customized. This causes the set of buttons to be persisted across sessions.

defaultset
Firefox only
Type: comma-separated list of item ids
The default set of displayed items on the toolbar. This should be set to a comma-separated list of item IDs from the toolbarpalette. For example, back-button,forward-button,print-button.


grippyhidden
Not in Firefox
Type: boolean
When set to true, the grippy will be hidden. When set to false, the default, the grippy will be shown.

grippytooltiptext
Not in Firefox
Type: string
The text to appear on the tooltip for the toolbar's grippy when the toolbar is collapsed. This would be used to label the grippy so that the user knows which toolbar it represents.


mode
Firefox only
Type: one of the values below
How the toolbarbuttons on the toolbar are displayed.
  • icons: Show only icons.
  • text: Show only text.
  • full: Show both.

toolbarname
Firefox only
Type: string
The name of the toolbar, which is listed on the Show/Hide toolbars menu.

[edit] Properties

Inherited from XUL element
align, allowEvents, boxObject, builder, className, collapsed, contextMenu, controllers, currentItem, database, datasources, dir, flex, height, hidden, id, left, listBoxObject, maxHeight, maxWidth, menu, minHeight, minWidth, observes, ordinal, orient, pack, persist, ref, resource, statusText, style, tooltip, tooltipText, top, value, width

Inherited from DOM element
attributes, childNodes, cloneNode, firstChild, lastChild, localName, namespaceURI, nextSibling, nodeName, nodeType, nodeValue, ownerDocument, parentNode, prefix, previousSibling, tagName

accessibleType
Type: integer
A value indicating the type of accessibility object for the element.

currentSet
Firefox only
Type: comma-separated list of strings
Holds a comma-separated list of the IDs of the items currently on the toolbar. For spacers, separators, and flexible spacers the following strings are used instead of IDs: "spacer", "separator", "spring". An empty toolbar has a currentSet value of "__empty".
You may change the current set of items by setting this property. Be careful, as setting this property doesn't automatically update the currentset attribute.

firstPermanentChild
Firefox only
Type: element
The first permanent child of the toolbar. A permanent child is one that is not customizable and remains on the toolbar. Items that are placed directly inside the toolbar without being in the toolbarpalette are permanent.

lastPermanentChild
Firefox only
Type: element
The last permanent child of the toolbar. A permanent child is one that is not customizable and remains on the toolbar. Items that are placed directly inside the toolbar without being in the toolbarpalette are permanent.

toolbarName
Firefox only
Type: string
The name of the toolbar.

[edit] Methods

insertItem( id, beforeNode, wrapper, beforePermanent )
Firefox only
Return type: element
Add an item with the given id to the toolbar. The new item is added just before the item given by the second argument. If the second argument is null, but the beforePermanent argument is true, the item is added to the beginning of the toolbar before the first permanent item. Otherwise, if the beforePermanent argument is false, the new item is added to the end of the toolbar. The third argument can be used to wrap the new item in another element. Usually, the last argument will be null as it is mainly for the use of the customize dialog.

The id should match an element in the toolbar's toolbarpalette. Some special ids may also be used to create special spacing items:

  • separator: A separator, which is drawn as a vertical bar.
  • spacer: A non-flexible space.
  • spring: A flexible space.

The method returns the DOM element for the created item.

Inherited from XUL element
blur, click, doCommand, focus, getElementsByAttribute

Inherited from DOM element
addEventListener, appendChild, dispatchEvent, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getElementsByTagName, getElementsByTagNameNS, hasAttribute, hasAttributeNS, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, removeEventListener, replaceChild, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS

[edit] Related

Elements
toolbarbutton, toolbargrippy, toolbaritem, toolbarpalette, toolbarseparator, toolbarset, toolbarspacer, toolbarspring, toolbox
Interfaces
nsIAccessibleProvider