XUL:toolbarbutton
From MDC
« XUL Reference home [ Examples | Attributes | Properties | Methods | Related ]
A button that appears on a toolbar. It is equivalent to a regular button except that it may be rendered differently. Typically, it is expected to have an image.
More information is available in the XUL tutorial.
Relevant accessbility guidelines
|
- Attributes
- accesskey, autoCheck, checkState, checked, command, crop, dir, disabled, dlgtype, group, image, label, oncommand, open, orient, tabindex, type, validate
- Properties
- accessKey, accessibleType, autoCheck, checkState, checked, command, crop, dir, disabled, dlgType, group, image, label, open, orient, tabIndex, type
[edit] Examples
(example needed)
[edit] Attributes
|
Inherited from XUL element |
- accesskey
- Type: character
- This should be set to a letter that is used as a shortcut key. This letter should be one of the characters that appears in the
labeltext for the element.
- autoCheck
- Type: boolean
- If this attribute is
trueor left out, the checked state of the button will be switched each time the button is pressed. If this attribute isfalse, the checked state must be adjusted manually. When autoCheck is true, the button type should be "checkbox" or "radio".
- checkState
- Type: integer, values
0,1, or2 - This attribute may be used to create three state buttons, numbered 0, 1 and 2. When in state 0 or 1, pressing the button will switch to the opposite state. When in state 2, pressing the button will switch to state 0. This means that the button acts like a checkbox except that there is a third state which must be set manually by adjusting the check state. If you wish to have different behavior for how the states are adjusted, set the autoCheck attribute to
falseand adjust the state with a script. The type attribute must be set tocheckboxfor buttons with a check state. Constants for the possible values for this attribute are in the nsIDOMXULButtonElement interface.
- checked
- Type: boolean
- Indicates whether the element is checked or not.
- Use
hasAttribute()to determine whether this attribute is set instead ofgetAttribute().
- crop
- Type: one of the values below
- If the label of the element is too big to fit in its given space, the text will be cropped on the side specified by the
cropattribute. An ellipsis will be used in place of the cropped text. If the box direction is reversed, the cropping is reversed.
-
start: The text will be cropped on its left side. -
end: The text will be cropped on its right side. -
left: Deprecated The text will be cropped on its left side. -
right: Deprecated The text will be cropped on its right side. -
center: The text will be cropped in the middle, showing both the start and end of the text normally. -
none: The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.
- dir
- Type: one of the values below
- The direction in which the child elements of the element are placed.
-
normal: The elements are placed left to right or top to bottom in the order they appear in the XUL code. -
reverse: The elements are placed right to left or bottom to top. This is reverse of the order in which they appear in the XUL code.
- disabled
- Type: boolean
- Indicates whether the element is disabled or not. If this element is set to
truethe element is disabled. Disabled elements are usually drawn with grayed-out text. If the element is disabled, it does not respond to user actions, it cannot be focused, and thecommandevent will not fire.
- dlgtype
- Type: one of the values below
- The dialog type of the button, used only when the button is in a dialog box. You can use this feature to replace the standard dialog box buttons with custom buttons, yet the dialog event methods will still function. For example, if the
dlgTypeis set toaccept, the button will replace the dialog box's accept button, which is usually labeledOK. Using this attribute on a button that is not in a dialog box has no effect. The following values can be used as the dialog type:
-
accept: The OK button, which will accept the changes when pressed. -
cancel: The cancel button which will cancel the operation. -
help: A help button for displaying help about the dialog. -
disclosure: A button to show more information. This might be a button or a disclosure triangle.
- group
- Type: string group name
- Buttons with type="radio" and the same value for their group attribute are put into the same group. Only one button from each group can be checked at a time. If the user selects one the buttons, the others in the group are unchecked.
- image
- Type: image URL
- The URL of the image to appear on the element. If this attribute is empty or left out, no image appears. The position of the image is determined by the dir and orient attributes.
- label
- Type: string
- The label that will appear on the element. If this is left out, no text appears.
- oncommand
- Type: script code
- This event handler is called when the command is activated. This occurs when a user selects a menu item or presses a keyboard shortcut attached to the command.
- open
- Type: boolean
- For the
menutype buttons, theopenattribute is set totruewhen the menu is open. Theopenattribute is not present if the menu is closed.
- orient
- Type: one of the values below
- Used to specify whether the children of the element are oriented horizontally or vertically. The default value depends on the element. You can also use the
-moz-box-orientstyle property.
-
horizontal: Child elements of the element are placed next to each other in a row in the order that they appear in the XUL source. -
vertical: Child elements of the element are placed under each other in a column in the order that they appear in the XUL source.
- tabindex
- Type: integer
- The tab order of the element. The tab order is the order in which the focus is moved when the user presses the "tab" key. Elements with a higher
tabindexare later in the tab sequence.
- type
- Type: string
- The type of button. If this attribute is not present, a normal button is created. You can set this attribute to the value
menuto create a button with a menu popup. This will typically cause the button to be displayed differently.
-
menu: Set the type attribute to the valuemenuto create a button with a menu popup. Place a menupopup element inside the button in this case. The user may click anywhere on the button to open and close the menu. -
menu-button: You can also use the valuemenu-buttonto create a button with a menu. Unlike themenutype, this type requires the user to press the arrow to open the menu, but a different command may be invoked when the main part of the button is pressed. This type of button would be used for browser's back and forward buttons. -
checkbox: Use this type to create a toggle button which will switch the checked state each time the button is pressed. -
radio: Use this type to create a radio button. You can also create a group of toolbarbutton using this type and the attribute group.
- validate
- Type: one of the values below
- This attribute indicates whether to load the image from the cache or not. This would be useful if the images are stored remotely or you plan on swapping the image frequently. The following values are accepted, or leave out the attribute entirely for default handling:
-
always: The image is always checked to see whether it should be reloaded. -
never: The image will be loaded from the cache if possible.
[edit] Properties
|
Inherited from XUL element Inherited from DOM element |
- accessibleType
- Type: integer
- A value indicating the type of accessibility object for the element.
- checkState
- Type: integer, values
0,1, or2 - Gets and sets the value of the checkState attribute.
[edit] Methods
|
Inherited from XUL element Inherited from DOM element |
[edit] Related
- Elements
- toolbar, toolbargrippy, toolbaritem, toolbarpalette, toolbarseparator, toolbarset, toolbarspacer, toolbarspring, toolbox
- Interfaces
- nsIAccessibleProvider, nsIDOMXULButtonElement