A single preference panel in a
prefpane is made up of two parts, the preferences descriptions, which specify the set of preferences that will be modified, and the user interface for adjusting those preferences. The former is specified using a
preferences element while the latter may be specified using other XUL elements.
Both may be specified directly as children of the
prefpane element, or the
src attribute may be used to put a pane in a separate file. In this latter case, the separate file should use an
overlay tag as its root tag since it will be loaded as an overlay to the main preferences window.
More information is available in the Preferences System article.
- helpURI, image, label, onpaneload, selected, src
- image, label, preferenceElements, preferences, selected, src
<prefpane id="paneGeneral" label="General" src="chrome://path/to/paneOverlay.xul"/>
<prefpane id="paneGeneral" label="General" onpaneload="onGeneralPaneLoad(event);"> <preferences> <preference id="pref_one" name="extensions.myextension.one" type="bool"/> ... more preferences ... </preferences> <checkbox label="Number one?" preference="pref_one"/> ... more UI elements ... </prefpane>
- Type: URI
- The URI of the help page associated with a preference panel. The URI will be opened using the help viewer when the help button is pressed.
- Type: script code
Code defined here is called when the pane has been loaded, much like the
loadevent for a window.
- The height (in pixels) of current pane's content.
Indicates whether the pane is fully loaded.
- Type: DOM Nodelist
- Holds a list of the UI elements in the pane that are attached to preferences.
DOMElement getPreferenceElement(in DOMElement startElement)
void userChangedValue(in DOMElement element);
The user changed the value in a widget that the preferences system does not automatically track state changes for (1) and the preference element associated with the widget should be updated based on the state held by the widget. For example, if you are using a listbox and the user changes the contents of the listbox (such as adding or removing an item) and you want to sync the changes back to a preference, you must write an
onsynctopreferencehandler for your listbox that returns the value to be written to the preference element, and then call the
userChangedValuefunction every time you edit the list in a way that should cause the preference's value to change.
- (1) an example of a widget that has state changes tracked for it includes the checkbox element, whose state is tracked automatically when the "command" event fires.
void writePreferences(in boolean flushToDisk);
- Writes all changes in this pane to preferences, optionally flushes to disk.
This event is fired on the pane element when the pane is fully loaded (e.g. after the overlay is merged.) You can put the handler for this event in the
onpaneloadattribute on the element.
Note that when using multiple
prefpanes in the same
prefwindow, you must not put the
<script> elements above the
prefpane elements, but instead below them. Otherwise the dialog will show erratic behavior and not display correctly.
<script> tags as in the following example for preference dialogs to work correctly:
When opening a dialog with multiple panes you must include the
toolbar feature in the call to
openDialog, for example:
window.openDialog("chrome://example/content/prefwin.xul", "", "chrome,toolbar");