Events

Events enable components throughout Alfred UI to respond to a number of different triggers, allowing you to bring a UI to life.

Use the events ARRAY key per component to define the events you are interested in.

{
  "type": "button",
  "text": "Press Me!",
  "events": [
    {
      "triggers": "actioned",
      "action": { ... }
    }
  ]
}

event Properties

The events ARRAY should contain event OBJECTs with the following properties:

triggers
ENUM | ARRAY of ENUM
Default: "actioned"

Fire the event when the trigger occurs on the component.

Value Description
"preload" Triggered after the UI has been built, before Alfred UI is shown.
"launched" Triggered after the Alfred UI has launched.
"quit" Triggered right before Alfred UI is quit.
"actioned" When a component has been actioned, e.g. a button pressed.
"changed" When a component has changed, e.g. a selection changed.
"typingstopped" When the user stops typing in a text component.
"mousedown" When the user mouses down on a component.
"mouseup" When the user left mouses up on a component.
"clicked" When the user clicks a component.
"doubleclicked" When the user double clicks a component.

One or more triggers can be provided by using an array, e.g. "triggers": ["actioned", "changed"]

Note

Components only respond to triggers relevant to that type of component. The actioned trigger is the most useful in many cases.

action
ACTION | ARRAY
Required

An action object, or an array of action objects to associate with this event. Multiple actions are treated as a single compound action.

These actions are run on the event thread and will block UI updates. Ensure any actions which contain scripts return immediately or use script async.

confirm
OBJECT

An optional confirmation before running the event.

message
STRING

The main message for the confirmation dialog.

iconpath
STRING

The path to an icon for this dialog.

informativetext
STRING

Some optional additional text for the confirmation dialog.

confirmbuttontext
STRING

Optional text on the confirmation button. Default "Confirm".

cancelbuttontext
STRING

Optional text on the cancel button. Default "Cancel".