Adding onclick function to a generated button
Posted: October 26th, 2017, 1:22 pm
Hello,
I'm having problems adding functions to newly generated buttons
It's looping through all the presets in the folder and generating a button for each of them.
I want that when you click on the button, the preset is applied to the layer.
But how can I make it so that each button has a unique function because right now everything is getting the same function.
Cheers
I'm having problems adding functions to newly generated buttons
Code: Select all
for(i = 0; i < files.length; i++){
var buttonX = mainWindow.add("button", undefined, presets[i]);
buttonX.onClick = function(){
mainLayer.applyPreset(presets[i]);
}
};
I want that when you click on the button, the preset is applied to the layer.
But how can I make it so that each button has a unique function because right now everything is getting the same function.
Cheers