FilePicker
class is available in all scripts to create a file picker.
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 XUL 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
|
init(java.lang.Object, java.lang.String, java.lang.String)
and init(org.xul.script.xul.model.XULWidget, java.lang.String, java.lang.String)
methods allow to initialize the FilePicker.var filepicker = new FilePicker(); filepicker.init(document, "openMode");
appendFilters(java.lang.String, java.lang.String)
method."XUL Files"
)"*.xul; *.xml"
)var filepicker = new FilePicker(); filepicker.appendFilters("The XUL files", "*.xul");In XUL 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 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence