opendialog Action

An action to show a macOS Open dialog to select a file.

{
  "opendialog": {
    "filetypes": "public.image",
    "folder": "~/Desktop",
    "prompt": "Open",
    "message": "Choose an Image",
    "setvariable": "picked_image",
    "action": { ... }
  }
}

Properties

canchoosefiles
BOOL
Default: true

Allows file selection.

canchoosefolders
BOOL
Default: false

Allows folder selection.

filetypes
ARRAY

An optional list of selectable UTI types e.g. public.png or public.image

folder
STRING

The initial folder when the Open dialog is shown.

prompt
STRING

The optional alternative button text for the main action prompt.

message
STRING

A small optional message for the top of the dialog.

multiselect
BOOL
Default: false

If multiple files can be selected.

setvariable
STRING

The name of the variable to place the selected file(s) into. The value of this variable will be an array if multiselect is set to true or a string otherwise.

action
ACTION | ARRAY

The action to run when the prompt button is selected.

Examples

Open a dialog to select and open images

{
  "type": "button",
  "text": "Pick images",
  "events": [
    {
      "triggers": "actioned",
      "action": {
        "type": "json",
        "src": {
          "opendialog": {
            "filetypes": "public.image",
            "multiselect": true,
            "folder": "~/Desktop",
            "prompt": "Open",
            "message": "Choose one or more images",
            "setvariable": "picked_images",
            "action": {
              "type": "json",
              "src": {
                "open": {
                  "type": "file",
                  "src": "{var:picked_images}"
                }
              }
            }
          }
        }
      }
    }
  ]
}