Skip navigation
natewhoscripts
Currently Being Moderated

Script Dialog Flashes Briefly Then Disappears

Jul 31, 2012 2:00 PM

Tags: #javascript #scripting #extendscript #automation

Hi All,

I'm trying to write a script for indesign CS6 mac which will open a panel and let me interact with it while indesign is open. I've tried several different code approaches, and with all of them, the window briefly opens and then closes immediately. If I add an infinite loop into the mix, it does not close, but remains  unresponsive. This is one version of the code:

#target inDesign
#targetengine main


function myScript(thisObj) {
          function myScript_buildUI(thisObj) {
                    var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "My Panel Name", [0, 0, 300, 300]);

                    res="group{orientation:'column', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
                              myStaticText: StaticText{text:'StaticText Text'},\
                              myEditText: EditText{text:'EditText text'},\
                              myButton: Button{text:'Button Name'},\
                              myCheckbox: Checkbox{text:'Checkbox Name'},\
                              myRadioButton: RadioButton{text:'RadioButton Name'},\
                              myDropDownList: DropDownList{properties:{items:['Item 1 Name', 'Item 2 Name', 'Item 3 Name', 'Item 4 Name']}},\
                              myListBox: ListBox{properties:{items:['Item 1 Name', 'Item 2 Name', 'Item 3 Name', 'Item 4 Name']}},\
                              myGroup: Group{orientation:'row', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
                                        myGroupItem1: Button{text:'Hi'},\
                                        myGroupItem2: Button{text:'Hello'},\
                                        myGroupItem3: Button{text:'Goodbye'},\
                              },\
                              myPanel: Panel{text:'Panel Name', orientation:'column', alignChildren:['right', 'fill'],\
                                        myPanelItem1: Button{text:'One'},\
                                        myPanelItem2: Button{text:'Two'},\
                                        myPanelItem3: Button{text:'Three'},\
                              },\
                              myProgressBar: Progressbar{text:'Progressbar Name', minvalue:0, maxvalue:100, value:50},\
                    }"
                    app.addEventListener("afterSelectionChanged", onSelChg, false ); 
                    
                    //Add resource string to panel
                    myPanel.grp = myPanel.add(res);

                    // DropDownList default selection
                    myPanel.grp.myDropDownList.selection = 2;//Item index starts at 0


                    //Setup panel sizing and make panel resizable
                    myPanel.layout.layout(true);
                    myPanel.grp.minimumSize = myPanel.grp.size;
                    myPanel.layout.resize();
                    myPanel.onResizing = myPanel.onResize = function () {this.layout.resize();}

                    return myPanel;
          }


          var myScriptPal = myScript_buildUI(thisObj);


          if ((myScriptPal != null) && (myScriptPal instanceof Window)) {
                    myScriptPal.center();
                    myScriptPal.show();
                    }
          }


          myScript(this);
function onSelChg()
{
    alert("hi");
    }

 

Any ideas?

Thanks!

 
Replies
  • Currently Being Moderated
    Jul 31, 2012 2:10 PM   in reply to natewhoscripts

    Du you have this?

     

    www.kahrel.plus.com/indesign/scriptui-1-11.pdf

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 31, 2012 2:17 PM   in reply to natewhoscripts

    To get a palette to stay open, you need (apart from setting an

    independent target engine, which you've done) to run if from the

    InDesign scripts palette. If you try to run it from ESTK it won't work.

     

    Ariel

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 31, 2012 2:20 PM   in reply to [Ariel]

    Good to know, Ariel.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 31, 2012 2:22 PM   in reply to [Ariel]

    Arïel wrote:

     

    To get a palette to stay open, you need (apart from setting an

    independent target engine, which you've done) to run if from the

    InDesign scripts palette. If you try to run it from ESTK it won't work.

     

    Ariel

     

    This was my experience in CS4 and previous—it wouldn't work if the engine didn't already exist. In CS5 and above, though, it will create the engine on the fly even from the ESTK.

     

    OP should use a targetengine other than "main", though.

     

    Jeff

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 31, 2012 2:34 PM   in reply to absqua

    Interesting. I haven't seen that mentioned anywhere. I'm still on CS4

    (and thoroughly enjoying it!).

     

    And yes, to be on the safe side avoid using "main" as your engine.

     

    Ariel

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 1, 2012 3:02 AM   in reply to [Ariel]

    Page 2 in the guide Larry mentioned, Ariël

     

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 1, 2012 7:23 AM   in reply to Peter Kahrel

    Peter

     

    Maybe for version 12 you can put it on page 1

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points