Highlighted

Script UI from Dialog to Palette

Advocate ,
Sep 25, 2020

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...


Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

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

TOPICS
Scripting

Views

83

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Script UI from Dialog to Palette

Advocate ,
Sep 25, 2020

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...


Adobe Community Professional
Correct answer by Manan Joshi | Adobe Community Professional

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

TOPICS
Scripting

Views

84

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 25, 2020 0
Advocate ,
Sep 25, 2020

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() {

....

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 25, 2020 0
Adobe Community Professional ,
Sep 25, 2020

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 25, 2020 2
Advocate ,
Sep 26, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 26, 2020 0