Luart
Comprehensive Windows framework to develop in Lua
modules > ui > opendialog

ui.opendialog ([title] , [allow_mutiple_selection] , [filters])

Displays a dialog box for the user to choose a file or set of files to be opened. The file(s) must exist physically on the drive.

Parameters

title

An optional string that indicates the title of the dialog box (use the default system title if not specified).

allow_multiple_selection

An optional boolean value that indicates if the dialog allow multiple files selection or not.

filters

An optional string that indicates filters. A filter is used to display only files with a specified pattern. If omitted, the dialog shows all files.
A filter is composed of a and a field, each separated by the character "|". For example, the string "All files (*.*)|*.*|Text files (*.txt)|*.txt" defines 2 filters :
  • A filter named "All files (*.*)" that correspond to the search pattern "*.*"
  • A filter named "Text files (*.txt)" that correspond to the search pattern "*.txt"

Return value

The function returns the selected file(s) as File object(s) or nil if no files have been choosen.

Example


local ui = require "ui"

-- open a dialog to choose an existing file
local file = ui.opendialog()

-- checks if a file has been selected
if file ~= nil then
	ui.info("File path : "..file.fullpath.."\nFile size : "..file.size.." bytes\nFile creation date : "..file.created.."\n")
end