Answered
View Palette
Hello everyone, everything good?
I'm trying to create a script that has two types of dialog boxes, a main and a second window, which when opened I can manipulate the elements of the main window. The solution would be a palette-type window, but I have no idea how to make it stay open when executed.
Is there any chance this pallete will be visible when executed? Thanks.
dlg = new Window("palette");
dlg.text = "Dialog";
dlg.orientation = "column";
dlg.alignChildren = ["center","top"];
array=[];
p1 = dlg.add("panel", undefined, undefined, {name: "p1"});
p1.text = "Panel";
p1.preferredSize.width = 150;
p1.orientation = "column";
p1.alignChildren = ["left","top"];
p1.spacing = 10;
p1.margins = 10;
var valor = 25.00;
b1 = dlg.add("button", undefined, undefined, {name: "b1"});
b1.text = "Adicionar";
b1.preferredSize.width = 150;
adiconar();
b2 = dlg.add("button", undefined, undefined, {name: "b2"});
b2.text = "Somar";
b2.preferredSize.width = 150;
dlg.layout.layout (true);
b1.onClick = function(){
adiconar();
}
function adiconar(){
t1 = p1.add("Button"); t1.text = "✔ Moldura 1 : R$ " + valor;
array.push([ t1.text.split("R$")[1] ]);
dlg.layout.layout (true);
}
b2.onClick = function(){
var soma_total = 0;
for (i = 0; i < array.length; i++) {
soma_total += Number(array[i]);
}
b2.text ="R$: "+ soma_total.toFixed(2).replace('.', ',').replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.');
}
dlg.show();