public class FilePicker |
---|
Modifier and Type | Method and Description |
---|---|
boolean | appendFilters(String description, String extensions)
Add a file filter to the FilePicker
|
File | getFile()
Return the selected File
|
void | init(Object parent, String mode)
set the mode of the FilePicker, usable in all scripts, including Javascript scripts. The parent can be a XULDocument or a XULWidget, or even be null
|
void | init(XULWidget parent, String title, String mode)
Same method for non Javascript scripts
|
int | show()
Show the FilePicker chooser an return the value
|
var filepicker = new FilePicker(); filepicker.init(document, "openMode");
"XUL Files"
)"*.xul; *.xml"
)var filepicker = new FilePicker(); filepicker.appendFilters("The XUL files", "*.xul");In Groovy:
FilePicker filepicker = new FilePicker(); filepicker.appendFilters("The XUL files", "*.xul");
<window title="FilePicker" width="400" height="400" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script> function open() { var filepicker = new FilePicker(); var parent = document.getElementById("open"); filepicker.appendFilters("The XUL files", "*.xul"); filepicker.init(parent, "Select File", "modeOpen"); var ret = filepicker.show(); if (ret == filepicker.returnOK) { var text = helper.getText(filepicker.file); var textbox = document.getElementById("text"); textbox.value = text; } } </script> <menubar> <menu label="File"> <menupopup> <menuitem id="open" label="Open" oncommand="open()"/> </menupopup> </menu> </menubar> <textbox id="text" multiline="true" value="" cols="30" rows="20"/> </window>
Copyright 2008-2020 Herve Girod. All Rights Reserved. Documentation and source under the LGPL licence