(How) Can I add a switch, radio button, or picker in an alert?

I’m trying to port a Drafts script (that I made myself) to Scriptable.

This script starts with a prompt that uses several UI elements to input data:

  • Several text fields
  • A radio button (“select” in Drafts terminology)
  • A picker

It looks like Scriptable only supports text fields in alerts?

(How) Can I add a switch, radio button, or picker in an alert?

As a workaround I’m going to try to let Launch Center Pro handle the input (using a list for both the radio button and the picker) and pass that to Scriptable, but it would be nice if this can be done fully within Scriptable.

1 Like

That turns out to work amazingly well!

In fact, I like it so much that I’m considering using Scriptable as an engine only (for this particular use case). To do that I would like to let LCP display the result (a single string) of (Scriptable’s) processing the input, instead of Scriptable. I can probably pass that result using x-callback-url’s x-success parameter, but…

How can I let LCP display a string? (Scriptable’s Alert)

I don’t think there’s an equivalent in Launch Center Pro to an alert. I know the QR scanner can display text it has decoded and there’s an option to speak text aloud, but unless you want to display it in an input prompt or list. Is there a particular reason you want to switch out of Scriptable to display the result rather than keeping the data in Scriptable and displaying it there?

I would view LCP as an initiator of automation - until and unless it develops considerably.

I would expect the bulk of the automation, including most of the UI, to be in Scriptable.

The question is: What can Scriptable do in UI terms?

1 Like

Consistency in dialogs (input, output).

But, if I can’t do it with LCP, Scriptable will do.

It’s much more important that I get the script to do what I want it to do (in a proper way):

By the way nowadays I use Launcher instead of LCP. But my comment about initiation still stands.

Would you happen to have a link to Launcher, and share some screenshots if you’ve got time? I’m just in a space where I’m figuring out the tools I’d like to use to fast track development of app ideas - which in my case requires users picking/selecting various text data (one item or many items) from screens.

I’m not sure what you mean by “picker” and “switch” but I made a guess. I have a form util that I use for stuff like this.

Imgur: scriptable-utils form demo

I just published some documentation on how to use my utils here: sloat.life. I plan on adding more tutorials there in the future.

Here’s the code that produced that demo:

import { form } from 'scriptable-utils';

type FormState = {
  textField1: string;
  textField2: string;
  radio: string[];
  switch: boolean;
  picker: string[];
  picker2: string[];
};

form<FormState>({
  title: 'Form demo',
  fields: {
    textField1: { type: 'textInput', label: 'Text field 1' },
    textField2: { type: 'textInput', label: 'Text field 2' },
    radio: { type: 'radio', label: 'Radio', options: ['A', 'B', 'C'] },
    switch: { type: 'checkbox', label: 'Switch' },
    picker: {
      type: 'selectMulti',
      label: 'Picker',
      options: ['A', 'B', 'C'],
    },
    picker2: {
      type: 'dropdown',
      label: 'Picker 2',
      options: ['A', 'B', 'C'],
    },
  },
})({ picker: [] });