native.showPopup() — Quick Look

Type function
Library native.*
Revision 2018.3333
Keywords native, showPopup, quick look, preview


Displays the operating system's default popup window for previewing/viewing documents.


native.showPopup( name, options )
name (required)

String. The string name of the popup to be shown. For the Quick Look plugin, use "quickLook".

options (required)

Table. A table that specifies the properties for the popup — see the next section for details.

Options Reference

Valid properties in the options table include the following:

files (required)

Table. A table of sub-tables, each specifying a file to view. Within each sub-table, filename indicates the file and baseDir indicates the system directory constant in which the file resides.

files = 
    { filename="myFile.txt", baseDir=system.ResourceDirectory },
startIndex (optional)

Table. The file index at which the preview will start. For instance, if you have two file sub-tables in the files table and you set this value to 2, it will preview the second file first, as opposed to starting at the first file. Default is 1, indicating the first file.

listener (optional)

Function. Listener function to be called when the popup is dismissed. This function is passed an event table which contains the following properties:

  • (string) — Value of "popup".
  • event.type (string) — Value of "quickLook".
  • event.action (string) — Value of "done".
  • event.file (table) — File table of the last item previewed prior to dismissing.


local function quickLookListener( event )
    print( )    --"popup"
    print( event.type )    --"quickLook"
    print( event.action )  --"done"
    print( event.file )    --file table of last item previewed prior to dismissing, for example: { filename="myFile.txt", baseDir=system.ResourceDirectory }

-- Quick Look options
local quickLookOptions = 
    files =
        { filename="myPDF.pdf", baseDir=system.ResourceDirectory },
        { filename="myImage.jpg", baseDir=system.ResourceDirectory },
    startIndex = 1,
    listener = quickLookListener

native.showPopup( "quickLook", quickLookOptions )