FileDialog - Kirix Documentation

Developer Resources

FileDialog

Overview

Class that represents a file chooser dialog.

Constructor

FileDialog()

Methods

FileDialog.getCaption
Gets the caption that is displayed in the file dialog.
FileDialog.getDefaultFilter
Gets the default filter index for the file dialog.
FileDialog.getDirectory
Gets the default directory of the file dialog.
FileDialog.getFilename
Gets the file name from the file dialog.
FileDialog.getFilenames
Returns an array of file names from the file dialog.
FileDialog.getFilter
Gets the filter string for the file dialog.
FileDialog.getPath
Gets the file name of the selected file, including the full directory path.
FileDialog.getPaths
Returns an array of the file names of the selected files that includes the full directory path.
FileDialog.setCaption
Sets the caption to display in the file dialog.
FileDialog.setDefaultFilter
Sets the default filter index for the file dialog.
FileDialog.setDirectory
Sets the default directory of the file dialog.
FileDialog.setFilter
Sets the filter string for the file dialog.
FileDialog.showDialog
Shows the file dialog.

Example

// create a new file dialog object
var dlg = new FileDialog;

// show these file types in the file dialogs filter
dlg.setFilter("Bitmap Files|*.bmp|JPEG Images|*.jpg;*.jpeg");

// show the dialog, and accept the results only if the
// user presses Ok

if (dlg.showDialog() == DialogResult.Ok)
{
    var files = dlg.getPaths();

    for (var f in files)
        alert(files[f]);
}

FileDialog.getCaption

function FileDialog.getCaption() : String

Returns

Returns the caption to display in the file dialog.

Description

Returns the caption to display in the file dialog.

FileDialog.getDefaultFilter

function FileDialog.getDefaultFilter() : Integer

Returns

Returns the default filter index for the file dialog.

Description

Returns the default filter index for the file dialog.

FileDialog.getDirectory

function FileDialog.getDirectory() : String

Returns

Returns the default directory of the file dialog.

Description

Returns the default directory of the file dialog.

FileDialog.getFilename

function FileDialog.getFilename() : String

Returns

Returns the file name from the file dialog.

Description

Returns the file name from the file dialog.

FileDialog.getFilenames

function FileDialog.getFilenames() : Array(String)

Returns

Returns an array of the selected files in the file dialog.

Description

Returns an array of the selected files in the file dialog. In order for the file dialog to return multiple paths, multi-selection mode must be enabled. See OpenFileDialog.setMultiselect()

FileDialog.getFilter

function FileDialog.getFilter() : String

Returns

Returns a string containing the current filter string for the file dialog.

Description

Returns the filter string for the file dialog.

FileDialog.getPath

function FileDialog.getPath() : String

Returns

Returns the name of the selected file, including the full directory path.

Description

Returns the name of the selected file, including the full directory path. If multiple files were selected in the file dialog, the first one will be returned.

FileDialog.getPaths

function FileDialog.getPaths() : Array(String)

Returns

Returns an array of the file names of the selected files that includes the full directory path.

Description

Returns an array of the file names of the selected files that includes the full directory path. In order for the file dialog to return multiple paths, multi-selection mode must be enabled. See OpenFileDialog.setMultiselect()

FileDialog.setCaption

function FileDialog.setCaption(text : String)

Arguments

text
The text to display as the caption in the file dialog.

Description

Sets the caption to display in the file dialog.

FileDialog.setDefaultFilter

function FileDialog.setDefaultFilter(index : Integer)

Arguments

index
The default index to which to set the file dialog filter.

Description

Sets the default filter to the value specified in the index parameter. This zero-based index indicates which filter string is shown by default. See the setFilter() method for more information.

FileDialog.setDirectory

function FileDialog.setDirectory(path : String)

Arguments

path
The new default directory path for the file dialog.

Description

Sets the default directory of the file dialog.

FileDialog.setFilter

function FileDialog.setFilter(text : String)

Description

Sets the filter string for the file dialog. A filter string is composed of one or more description/extension pairs. The file dialog will allow the user to search for files with the type(s) specified in the filter string. A filter string for .bmp and .jpg/.jpeg files might look something like this: "Bitmap Files|*.bmp|JPEG Images|*.jpg;*.jpeg"

FileDialog.showDialog

function FileDialog.showDialog() : DialogResult

Returns

Returns DialogResult.Ok when the dialog is closed by pressing "OK" or equivalent, and DialogResult.Cancel if the dialog is closed by pressing "Cancel" or equivalent.

Description

Shows a file dialog and returns DialogResult.Ok if the user closes the file dialog by pressing "OK", or the equivalent, and DialogResult.Cancel if the user closes the file dialog by pressing "Cancel", or the equivalent.