XUL:prefwindow
From MDC
« XUL Reference home [ Examples | Attributes | Properties | Methods | Related ]
A specialized window used for preference dialogs. This element should be used in place of the window tag and should contain one or more prefpane elements. A row of buttons appears across the preference dialog, one for each prefpane. Each pane will usually group together a set of related preferences. If there is only one prefpane, the navigation area will be hidden.
On platforms where the convention is to apply changes immediately, the preferences are adjusted as soon as the user interface element is changed. On other platforms, the preferences are not applied until the dialog is closed.
You can open a preference window using a window's openDialog method as with other dialogs. You can pass the id of a particular pane as the fourth argument to openDialog to open a specific pane by default. You can also set the lastSelected attribute on the prefwindow tag to the id of the pane to start with. Normally, you would not set this attribute as it will be set automatically such that the default pane is the same as the one showing when the preferences dialog was last closed.
More information is available in the Preferences System article.
- Attributes
- buttonalign, buttondir, buttonorient, buttonpack, buttons, defaultButton, lastSelected, onbeforeaccept, ondialogaccept, ondialogcancel, ondialogdisclosure, ondialoghelp, onpaneload, title, type
- Properties
- buttons, currentPane, defaultButton, lastSelected, preferencePanes, type
- Methods
- acceptDialog, addPane, cancelDialog, centerWindowOnScreen, getButton, openSubDialog, openWindow, showPane
[edit] Examples
<prefwindow xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<prefpane id="saveoptions" label="Backups">
<preferences>
<preference id="pref-backup" name="myapp.mybackups" type="bool"/>
<preference id="pref-backupduration" name="myapp.mybackups.duration" type="int"/>
</preferences>
<checkbox label="Automatically Save Backups" preference="pref-backup"/>
<textbox label="Duration:" preference="pref-backupduration"/>
</prefpane>
</prefwindow>
[edit] Attributes
|
Inherited from XUL element |
- buttonalign
- Type: string
- The value of the align attribute for the box containing the buttons.
- buttonorient
- Type: string
- The value of the orient attribute for the box containing the buttons.
- buttonpack
- Type: string
- The value of the pack attribute for the box containing the buttons.
- buttons
- Type: comma-separated list of the values below
- A comma-separated list of buttons to appear on the dialog box. The buttons will be placed in suitable locations for the user's platform and basic event handling will be performed automatically. The following values can be used in the list:
-
accept: The OK button, which will accept the changes when pressed. This button will also be the default button. -
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. -
extra1: An optional additional button. You can set its label with thebuttonlabelextra1attribute. -
extra2: A second optional additional button. You can set its label with thebuttonlabelextra2attribute.
- defaultButton
- Type: string
- Normally this attribute should not be set, but if it is, it specifies the default button in the dialog. Typically, this means that the button will be activated when the Enter key is pressed. This should be set to one of the same values as those for the buttons attribute.
- lastSelected
- Type: string
- Set this to the id of the last selected pane. It will be opened by default the next time the preferences dialog is opened.
- onbeforeaccept
- Type: script code
- The code in this attribute is called when the OK button is pressed or the acceptDialog method is called.
- ondialogaccept
- Type: script code
- The code in this attribute is called when the accept button is pressed, or when the acceptDialog method is called. If the handler returns
true, the dialog will indeed go away, but if it returnsfalseit will not.
- ondialogcancel
- Type: script code
- The code in this attribute is called when the "cancel" button is pressed or when the cancelDialog method is called. If the routine returns true, the dialog will indeed go away, but if it returns false it will not.
- ondialogdisclosure
- Type: script code
- The code in this attribute is called when the "disclosure" button is pressed.
- ondialoghelp
- Type: script code
- The code in this attribute is called when the "help" button is pressed.
- onpaneload
- Type: script code
- Code defined here is called when the pane has been loaded, much like the
loadevent for a window.
- title
- Type: string
- The text to appear in the title bar of the window.
- type
- Type: string
- Set this attribute to
childfor preference dialogs that are child dialogs of a main preferences window. This ensures that the preferences are only saved when the main dialog is closed, if this is the appropriate behaviour for the platform.
[edit] Properties
|
Inherited from XUL element Inherited from DOM element |
- buttons
- Type: comma-separated list of the values below
- A comma-separated list of buttons to appear on the dialog box. The buttons will be placed in suitable locations for the user's platform and basic event handling will be performed automatically. The following values can be used in the list:
-
accept: The OK button, which will accept the changes when pressed. This button will also be the default button. -
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. -
extra1: An optional additional button. You can set its label with thebuttonlabelextra1attribute. -
extra2: A second optional additional button. You can set its label with thebuttonlabelextra2attribute.
- currentPane
- Type: prefpane element
- Reference to the currently displayed pane. To change the current pane, use the showPane method.
- defaultButton
- Type: string
- Normally this attribute should not be set, but if it is, it specifies the default button in the dialog. Typically, this means that the button will be activated when the Enter key is pressed. This should be set to one of the same values as those for the buttons attribute.
- lastSelected
- Type: string
- Set this to the id of the last selected pane. It will be opened by default the next time the preferences dialog is opened.
- preferencePanes
- Type: DOM NodeList
- Holds a list of all the prefpane elements in the window.
[edit] Methods
|
Inherited from XUL element Inherited from DOM element |
- acceptDialog()
- Return type: no return value
- Accepts the dialog and closes it, similar to pressing the OK button.
- addPane( prefpane )
- Return type: no return value
- Append a prefpane to a list of panes.
- cancelDialog()
- Return type: no return value
- Cancels the dialog and closes it, similar to pressing the Cancel button.
- centerWindowOnScreen()
- Return type: no return value
- Centers the dialog on the screen.
- getButton( type )
- Return type: button element
- Returns the button element in the dialog corresponding to the given type.
- openSubDialog( url, features, params )
- Return type: window
- Opens a child modal dialog. Usually this method would be used to allow the user to configure advanced options. The arguments are similar to the window's
openDialogmethod except that the window name does not need to be supplied. The url should be a XUL file. If the child dialog is also a prefwindow, set its type attribute tochildso that preferences will be saved properly when the main dialog is closed.
- openWindow( windowtype, url, features, params )
- Return type: window
- Open a child window. The windowtype is a string specifying a window type. If a window with that type is already open, this method will just switch that window to the front and focus it instead of opening another window. If a window of the type is not open, a new one is opened displaying the supplied url.
- showPane( prefpane )
- Return type: no return value
- Switch to a particular pane.
[edit] Related
TBD