• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Script UI from Dialog to Palette

Community Expert ,
Sep 25, 2020 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...


TOPICS
Scripting

Views

633

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
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 25, 2020 Sep 25, 2020

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

Votes

Translate

Translate
Community Expert ,
Sep 25, 2020 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() {

....

Votes

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
community guidelines
Community Expert ,
Sep 25, 2020 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

Votes

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
community guidelines
Community Expert ,
Sep 26, 2020 Sep 26, 2020

Copy link to clipboard

Copied

LATEST

Thanks Manan!

With a a few changes in the order and the button handler I was able to do it.

Votes

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
community guidelines