dialogs#

local dialogs = require 'dialogs'

The dialogs module provides standard UI dialogs.

Classes#

class dialogs.FileDialog#

The FileDialog class provides a window that allows users to select a file or folder for opening or saving.

See also

See the new() method for creating a new FileDialog.

Example#
local dialogs = require 'dialogs'

local of = dialogs.FileDialog.new('open-file')

-- specify a function to be called when the user confirms
of.confirmcallback = function(path)
    -- do something with the file at path
end

-- only show TacO marker packs
of.filefilters = {'.taco'}

of:show()
confirmcallback: function#

A function that will be called whenever the confirmation button (‘Open’ or ‘Save’) is pressed by the user.

This function will be called with a single argument: the full path of the selected file/folder.

Version History

Version

Notes

0.3.0

Added

filefilters: sequence#

A list of file extensions to display within the dialog.

Note

The extension should include the leading ..

Important

To show all files, set this attribute to nil. An empty table will not show any files.

Version History

Version

Notes

0.3.0

Added

new(mode)#

Create a new FileDialog.

Parameters:

mode (string) – The dialog mode. See below.

Return type:

FileDialog

Dialog Mode mode controls how the FileDialog will behave and must be one of the following values:

  • 'open-file'

  • 'save-file'

Warning

'save-file' dialog will allow users to specify existing files. Module authors should confirm that the user wishes to overwrite existing files if they are chosen.

Version History

Version

Notes

0.3.0

Added

gotodesktop()#

Navigate this file dialog to the ‘Desktop’ virtual folder.

Version History

Version

Notes

0.3.0

Added

gotothispc()#

Navigate this file dialog to the ‘This PC’ virtual folder.

Version History

Version

Notes

0.3.0

Added

gotopath(path)#

Navigate this file dialog to the given path.

Parameters:

path (string) – A full path to a folder.

Version History

Version

Notes

0.3.0

Added

show()#

Show this file dialog.

The dialog will be shown until the user presses either the confirmation or cancel buttons.

On confirmation, the confirmcallback function will be called if set.

Version History

Version

Notes

0.3.0

Added

class dialogs.MessageDialog#

A simple dialog that displays a message and optional icon with an ‘OK’ button.

See also

See the new() method for creating a new MessageDialog

Example#
local dialogs = require 'dialogs'

local d = dialogs.MessageDialog.new('Test Dialog','This is a test!','feedback')

d:show()
new(title, message[, icon])#
Parameters:
  • title (string) – The dialog title.

  • message (string) – A message to display. This can include newline ('\n') characters to display multiple lines of text.

  • icon (string) – (Optional) An icon name. If absent, no icon is displayed.

Return type:

MessageDialog

Version History

Version

Notes

0.3.0

Added

show([wait])#
Parameters:

wait (boolean) – (Optional) If true, this method will not return until the OK button is pressed and the dialog is closed.

Version History

Version

Notes

0.3.0

Added