XUL Programmer's Reference Manual

<titledbutton />

Attributes Common Children
value * * *
class  
align  
onclick  
oncommand  
id  
tooltip  
default  
disabled  
toggled  
src  
crop  

 
 
value
Description
value is a required attribute used to provide a label for the button.
Syntax
<titledbutton value="string" />
Example
<titledbutton id="pushme" class="push" value="Push Me" />
Notes
It is legal not to provide a value for a button, but the button may be invisible if there is not value to constrain the size of the actual button and no styling information that specifies its position and size.

 

 

onclick
Description
onclick is an event listener attribute used for adding functionality to XUL buttons. 
Syntax
<titledbutton onclick="javascript statements or javascript function call"
Example
<titledbutton value="Print" id="print" onclick="alert('Printing Document'); Print();" />
Notes
The onclick event listener is a way to invoke commands from buttons. Note that oncommand is the preferred way to attach an event handler to a button. onclick is deprecated, though still available.

The click event is fired whenever the user clicks the button. You can put the JavaScript inline with the event listener, you can call JavaScript functions defined in the <head> section of the XUL file in a <html:script>...</html:script> element, of you can call JavaScript functions defined in a separate source file which is loaded with the <html:script language="javascript" src="source_file_name.js" /> construction.

 
 
 
oncommand
Description
oncommand is an event listener attribute used for adding functionality to XUL buttons. 
Syntax
<titledbutton oncommand="javascript statements or javascript function call"
Example
<titledbutton value="Print" id="print" oncommand="alert('Printing Document'); Print();" />
Notes
The oncommand event listener is a common way to invoke commands from buttons. It replaces onclick as the primary way to attach an event handler to a titlebutton.

You can put the JavaScript inline with the event listener, you can call JavaScript functions defined in the <head> section of the XUL file in a <html:script>...</html:script> element, of you can call JavaScript functions defined in a separate source file which is loaded with the <html:script language="javascript" src="source_file_name.js" /> construction.


 
tooltiptext
Description
tooltiptext is an optional attribute used to specify tooltip text for the button.
Syntax
<titledbutton tooltiptext="string" />
Example
<titledbutton id="send_mail" class="push" tooltiptext="Send Mail (Ctrl + M)" />
Notes
If you want to display longer or structured text within the tooltip window, you must use the tooltip attribute instead

 
 

 

default
Description
default is an optional attribute used to specify which button in a group is the default.
Syntax
<titledbutton default="true | false" />
Example
<titledbutton id="quit" default="true" />
Notes
None.
 
disabled
Description
disabled is an optional attribute used to gray out buttons that are disabled.
Syntax
<titledbutton disabled="true | false" />
Example
<titledbutton id="new" class="push" disabled="true" />
Notes
You can use JavaScript to check this attribute and determine whether a given operaton is enabled or not, as in the following example:
 
XXX insert HelpBack() function example here. XXX


 

toggled
Description
toggled is an optional attribute used to specify the toggle state of a button.
Syntax
<titledbutton toggled="0 | 1 | 2" />
Example
<titledbutton id="local" class="push" toggled="1" />
Notes
0 means that toggling is off, 1 means that it's on, and 2 means that the toggling is mixed.

 

 

src
Description
src is an optional attribute for loading button images.
Syntax
<titledbutton src="URL" />
Example
<titledbutton id="security" src="images\lock_and_key.gif" />
Notes
None.

 

 

crop
Description
crop is an optional attribute for specifying which part of a button's text, if any, will be cropped if it is too large.
Syntax
<titledbutton id="string" value="Button Name" crop="left | right | none | center" >
Example
<titledbutton id="string" value="Very Long Button Name" crop="none" >
Notes
None.

Last updated: 3/21/00 Ian Oeschger