Hello,
I’m a little late to this Scriptable party, but glad to have discovered this app. How cool!
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.