i have listbox item_1 and item_2 and more but for the sake of it this is enough.
this is my code
when listbox item_1 is selected and item string is item_1 then fire the code for that only.
listBox.onDoubleClick = function () {
//alert (listBox.selection);
if (listBox.selection = "item_1") {
listBox_pressed()
}
else
}
issue am having is executing code even when i click other list items.
full code
// ScriptUI Listboxes
var counter = 0;
var window = new Window("palette", "Listbox", undefined);
window.orientation = "column";
var listBox = window.add("listbox", undefined, []);
listBox.selection = 0;
listBox.size = [200, 100];
var buttonGroup = window.add("group", undefined, "buttonGroup");
buttonGroup.orientation = "row";
var addButton = buttonGroup.add("button", undefined, "+");
addButton.size = [30, 30];
var minusButton = buttonGroup.add("button", undefined, "-");
minusButton.size = [30, 30];
addButton.onClick = function () {
counter++;
listBox.add("item", "Item_"+counter.toString());
}
minusButton.onClick = function() {
if(listBox.selection != null) {
counter--;
listBox.remove(listBox.selection);
}
}
/////////////////////////////////////======================================================================================================
listBox.onDoubleClick = function () {
//alert (listBox.selection);
if (listBox.selection = "item_1") {
listBox_pressed()
}
else
}
/////////////////////////////////////======================================================================================================
function listBox_pressed(){ // main function
myComp = app.project.activeItem;
mySolid = myComp.layers.addSolid([0,0,0], "Solid", myComp.width, myComp.height,1);
}
window.center();
window.show();
sir when the script starts when i click button it adds items to list like this
item_1
item_2
item_3 and so on
now based on each item string i want to fire my custom code and not by item index.
so if item_1 is double clicked then fire my custom code use
listBox_pressed()
can you just show me one seperate code for listbox item_1 when double clicked my custom code should fire using if statement.
if listbox
so this code ##
if (listBox.selection = "item_1") {
listBox_pressed()
}
else
}
executes on any item rather than just item_1 only