Multiselect from UITable

Hello,

I’m a little late to this Scriptable party, but glad to have discovered this app. How cool! :partying_face:

At the moment I’m learning how to prompt a user with a list of items. Here’s my sample script;

// Define the array of animals
let animals = ["Cat", "Dog", "Mouse"]

// Create a table
let table = new UITable()

// Create a header row
let headerRow = new UITableRow()
headerRow.isHeader = true
headerRow.addText("Animals")
table.addRow(headerRow)

// Create a row for each animal
for (let animal of animals) {
  let row = new UITableRow()
  row.addText(animal)
  row.onSelect = () => {
    console.log(`Selected ${animal}`)
  }
  table.addRow(row)
}

// Present the table
table.present()

My script allows the user to select one animal from the prompt. But I have a couple of questions;

  • How could we allow the user to select multiple animals?
  • Are their either Tickboxes or Radio Select UI elements?
  • Perhaps UITable() is the wrong solution for what I’m trying to achieve?

My aim being to prompt the user with a list, and have them select either none or several items from that list prompt, and then their selected items returned to the console.log(). A method of multiselect as such.

This might help

2 Likes

Hey thanks @supermamon !

With your suggestion, I’ve now figured out how Scriptable files save with iCloud Drive, and how easy it is to load modules in. This is way cool! I think I’m a step closer to writing/updating my scripts via VS Code now.

Regarding the multi-select uiPickerTable, it works well. I was kind of assuming that this would be a core feature as such, but I’m very new here with lots to learn - always keen to understand different ways people are doing things.

Thanks again!

1 Like