File Dialog API

The file dialog API provides functions for opening files and folders. Example opening files:

editor_fileDialog.openFile(
  -- callback called when user selects and opens the file
  -- will not be called if it cancels the operation
  function(data)
    -- data contains a table with file information
  end, {{"Camera Path Files",".camPath.json"}}, false, "")

API functions:


bool editor.openFile(function callbackFn, string filenameSuffix, bool selectFolder, string defaultPath = “/”)

Open a windows to open a file or folder

:param callbackFn: Callback funtion, see editor_fileDialog::callbackFn :param filenameSuffix: Filename suffix (eg: {{"Any files", "*"},{"Images",{".png", ".dds", ".jpg"}},{"DDS Files",".dds"}}) :param selectFolder: Select a folder or a file :param defaultPath: Default path the dialog will open with :param withPreview: Display a preview of the selected file within the file dialog window

bool editor.saveFile(function callbackFn, string filenameSuffix, bool selectFolder, string defaultPath = “/”)

Open a windows to save a file or folder

:param callbackFn: Callback funtion, see editor_fileDialog::callbackFn :param filenameSuffix: Filename suffix (eg: {{"Any files", "*"},{"Material file",".materials.json"}}) :param selectFolder: Select a folder or a file :param defaultPath: Default path the dialog will open with

callbackFn(table data)

This function doesn’t exist in the module, it is an example of which type of function you need to use as a callback for editor_fileDialog.openFile or editor_fileDialog.saveFile

Function called when the user interacted with the file dialog

  • data - A table with data about the file or folder selected
Index name Avaibility Type Example
action Any Action string save or open
path Any Action string \art\
filename if selectFolder is false string test42.dae
filepath if selectFolder is false string \art\test42.dae
stat if action is open table same as BNGBase::FS::IFileSystem::stat()
filestat if action is save string overwrite or new
filetype if action is open table {"DDS Files",".dds"}
Last modified: December 7, 2021

Any further questions?

Join our discord
Our documentation is currently incomplete and undergoing active development. If you have any questions or feedback, please visit this forum thread.