Copy link to clipboard
Copied
Hello...
I have a nice working script with a Script UI Dialog. When I try to change it to a Palette, It will execute as such in InDesign, but the OK button don’t trigger the script. What I’m doing wrong... or missing.
My script start like...
#targetengine "session";
var w = new Window("palette");
...
and the script is called with this...
You will need to explicitly add the ok button handler here, dialog window type does that automatically but for palette we need to add it ourselves. So something like the following should work
button1.onClick = function()
{
alert("Your code goes here")
app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Modifier les nombres...");
w.close()
}
-Manan
Copy link to clipboard
Copied
my message have been cut...
Below are teh code to trigger the main function.
...
var button1 = w.add("button", undefined, undefined, {name: "OK"});
button1.helpTip = "Escape to Cancel";
button1.text = "OK";
var result = w.show();
if (result == 1) {
app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Modifier les nombres...");
}
function main() {
....
Copy link to clipboard
Copied
You will need to explicitly add the ok button handler here, dialog window type does that automatically but for palette we need to add it ourselves. So something like the following should work
button1.onClick = function()
{
alert("Your code goes here")
app.doScript("main()", ScriptLanguage.javascript, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Modifier les nombres...");
w.close()
}
-Manan
Copy link to clipboard
Copied
Thanks Manan!
With a a few changes in the order and the button handler I was able to do it.