Skip to content

Instantly share code, notes, and snippets.

@zlovatt
Created October 13, 2020 19:06
Show Gist options
  • Save zlovatt/466105163b921690527342e7d2c36166 to your computer and use it in GitHub Desktop.
Save zlovatt/466105163b921690527342e7d2c36166 to your computer and use it in GitHub Desktop.
Example script for creating a listbox via aequery
(function () {
// Set path below to your aeq.js path
//@include "path/to/aequery.js"
function createPanel() {
var win = aeq.ui.createWindow("Listbox Test");
var pnl = win.addPanel("List");
pnl.set({
orientation: "row",
alignment: ["fill", "fill"],
alignChildren: ["fill", "fill"]
});
var listbox = pnl.addListBox(
["abc", "def", "ghi", "jkl", "mno", "pqr", "stu", "vwx", "yz"],
undefined,
undefined,
{
multiselect: true
}
);
var grpListBoxMeta = pnl.addGroup({
orientation: "column"
});
grpListBoxMeta.addButton("+", function () {
var userInput = prompt("Type something in...", "Item Name Here");
if (!userInput) {
return;
}
listbox.addItem(userInput);
});
grpListBoxMeta.addButton("-", function () {
var selectedItems = listbox.getSelection();
if (!selectedItems) {
return;
}
for (var ii = 0, il = selectedItems.length; ii < il; ii++) {
var selectedItem = selectedItems[ii];
listbox.removeItem(selectedItem);
}
});
win.addButton("Close Panel", function () {
win.close();
});
win.show();
}
createPanel();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment