Prefwindow

   Mozilla 1.8

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.

Example:

    <prefwindow>
      <prefpane id="saveoptions" label="Backups">
        <preference>
          <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>

Attributes:

buttonalign buttondir buttonorient buttonpack buttons
defaultButton lastSelected onbeforeaccept ondialogaccept ondialogcancel
ondialogdisclosure ondialoghelp onpaneload title type

Properties and Methods:

acceptDialog addPane buttons cancelDialog centerWindowOnScreen
currentPane defaultButton getButton lastSelected moveToAlertPosition
openSubDialog openWindow preferencePanes showPane type

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
ref
removeelement
sortDirection
sortResource
sortResource2
statustext
style
template
tooltip
tooltiptext
top
uri
wait-cursor
width

buttonalign

Type: string

The value of the 'align' attribute for the box containing the buttons.

buttondir

Type: string

The value of the 'dir' 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:

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

This event is fired before the dialogaccept event and before the preferences have been written. You can return false or call the event's preventDefault method as necessary to prevent the preferences from being written.

ondialogaccept

Type: script code

The code in this attribute is called when the OK button is pressed, or when the acceptDialog function is called.

ondialogcancel

Type: script code

The code in this attribute is called when the Cancel button is pressed, or when the cancelDialog function is called.

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

This event is fired when a new pane is selected and loaded, or when the first pane is loaded.

title

Type: string

The text to appear on the title bar of the preference dialog.

type

Type: string

Set this attribute to "child" for 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.


Properties and Methods:

Inherited from XUL Element:

align
allowEvents
blur
boxObject
boxObject.element
boxObject.getLookAndFeelMetric
boxObject.height
boxObject.screenX
boxObject.screenY
boxObject.width
boxObject.x
boxObject.y
builder
className
click
collapsed
contextMenu
controllers
database
datasources
dir
doCommand
flex
focus
getElementsByAttribute
height
hidden
id
left
maxHeight
maxWidth
menu
minHeight
minWidth
observes
ordinal
orient
pack
persist
ref
resource
statusText
style
tooltip
tooltipText
top
width

Inherited from Element:

addEventListener
appendChild
attributes
childNodes
cloneNode
dispatchEvent
firstChild
getAttribute
getAttributeNS
getAttributeNode
getAttributeNodeNS
getElementsByTagName
getElementsByTagNameNS
hasAttribute
hasAttributeNS
hasAttributes
hasChildNodes
insertBefore
isSupported
lastChild
localName
namespaceURI
nextSibling
nodeName
nodeType
nodeValue
normalize
ownerDocument
parentNode
prefix
previousSibling
removeAttribute
removeAttributeNS
removeAttributeNode
removeChild
removeEventListener
replaceChild
setAttribute
setAttributeNS
setAttributeNode
setAttributeNodeNS
tagName

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 the list of panes.

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:

cancelDialog ( )

Return Type: no return value

Cancels the dialog and closes it, similar to pressing the Cancel button.

centerWindowOnScreen

Type: no return value

Centers the dialog on the screen.

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.

getButton ( type )

Return Type: button element

Returns the button element in the dialog corresponding to the given type.

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.

moveToAlertPosition

Type: no return value

Moves and resizes the dialog to a position and size suitable for an alert box.

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 openDialog method 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 to "child" so 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 window type 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.

preferencePanes

Type: DOM NodeList

Holds a list of all the prefpane elements in the window.

showPane ( prefpane )

Return Type: no return value

Switch to a particular pane.

type

Type: string

Gets and sets the value of the type attribute.


Copyright (C) 1999 - 2004 XulPlanet.com