Beta software, written entirely by AI.Nothing has been reviewed line by line by a human or security-audited. No warranty, no liability: you use it at your own risk.Read more
Skip to content

Field kinds ​

A field describes one input of a form. The editor draws the form; your plugin never draws UI. The same field objects are used in two places:

  • host.settings.page(fields): the plugin's settings window (the gear button in the Plugins window).
  • fields of host.registerAction({...}): the form the user fills in when binding the action to a widget event.
js
{ key: 'volume', label: 'Volume', kind: 'Slider', min: 0, max: 100, step: 5, default: 50 }

key is the name under which the value arrives (settings.volume in an action, host.settings.get().volume in a settings page). label is the text next to the input. kind is one of the names below.

The kinds ​

KindThe user seesValue in your scriptUses these options
Texta single-line text boxstringplaceholder, default, allowVariables
Passworda hidden text boxstring (stored as plain text in JavaScript plugins)placeholder
Numbera number boxnumbermin, max, step, default
Slidera slider with the value shownnumbermin, max, step, default
Boola checkbox or switchtrue / falsedefault
Selecta dropdownthe chosen option's value (string)options, default
Segmenteda row of buttons, one activethe chosen option's value (string)options, default
Filea path box with a Browse button (native file picker)the path (string)fileFilter
Listrepeated rows, the user adds and removes theman array of objectsitemFields
Noticeread-only warning textnone, never savedlabel, description
Buttona buttonnonenot usable from JavaScript (see below)

Options ​

OptionApplies toMeaning
descriptionallHelp text under the field.
placeholdertext kindsA hint shown while the box is empty.
defaultvalue kindsThe initial value. Also what settings and host.settings.get() hold until the user changes it.
min, max, stepNumber, SliderLimits and increment.
optionsSelect, SegmentedA fixed list of { value, label }. Optional group indents the row as Group › Item, optional icon shows an icon.
allowVariablesTextShows the {var} insert button. You receive the raw text with the {...} still in it. Read the value yourself with host.variables.get.
visibleWhenallShow the field only when another field has a value, written "key=value", for example "mode=pause". Inside a List row it is checked against that row's own values.
fileFilterFileRequired. A Windows file filter such as "Audio files (*.wav;*.mp3)|*.wav;*.mp3".
itemFieldsListRequired. The fields of one row, using any kind above. Row keys you did not declare are kept across a save.
dependsOn, optionsSource, commanddynamic dropdowns and buttonsThese need code in the server (official C# plugins only) and do nothing in a JavaScript plugin.

Examples ​

A settings page with several kinds

js
host.settings.page([
  { kind: 'Notice', key: 'n', label: 'Talks to the hub on your network.' },
  { key: 'host', label: 'Hub address', kind: 'Text', placeholder: '192.168.1.20' },
  { key: 'mode', label: 'Mode', kind: 'Segmented', default: 'auto',
    options: [{ value: 'auto', label: 'Auto' }, { value: 'manual', label: 'Manual' }] },
  { key: 'level', label: 'Level', kind: 'Slider', min: 0, max: 100, step: 5, default: 50,
    visibleWhen: 'mode=manual' },
  { key: 'token', label: 'Token', kind: 'Password' },
  { key: 'log', label: 'Write to file', kind: 'File', fileFilter: 'Text files (*.txt)|*.txt' },
])

A list

js
host.settings.page([
  { key: 'lights', label: 'Lights', kind: 'List', itemFields: [
    { key: 'name', label: 'Name', kind: 'Text' },
    { key: 'port', label: 'Port', kind: 'Number', min: 1, max: 65535, default: 8080 },
  ] },
])
const lights = host.settings.get().lights   // [{ name: 'Desk', port: 8080 }, ...]

An action form that can use variables

js
host.registerAction({
  type: 'myplugin.say', name: 'Say', run(context, settings) { host.log(settings.text) },
  fields: [{ key: 'text', label: 'Text', kind: 'Text', allowVariables: true }],
})

Where the values live ​

  • Settings page: stored in settings.json in the plugin folder. Only declared keys are kept. host.settings.get() merges saved values over the defaults. Users can also open the file, so validate what you read.
  • Action form: stored inside the profile, next to the button that uses the action, and passed to run as settings.

Form labels can be translated through locales/<language>.json, see JavaScript host API. The general behavior of settings pages is in Settings pages.

Macro Grid sites: PC · Phone · Plugins
Released under the MIT License. Beta software, written entirely by an AI assistant, provided as is without warranty.