2 Replies Latest reply on Jul 30, 2013 1:41 PM by rekros6

    [JS][ScriptUI] InDesign loses focus




      may someone help me with my "focusing" problem? When I make a ScriptUI dialog and set a Window element (i.e. EditText) property to active, InDesign (application) loses its top-level hierarchy in MS Windows after "OK" or "Cancel". It can be demonstrated on following simple script. If I hit "Cancel" another running application gets into focus instead of InDesign. When "OK" is pressed the same behaviour occurs for a moment before the new document, page and text frames are created. When active property is removed from myDial.formField or set to "false", everything works well.


      res =
          "dialog {properties: {borderless: false, closeButton: false}, text: 'Form:', \
              formField: EditText {text: 'Enter Name', justify: 'center', preferredSize: [170,30]}, \
              okBtn: Button {text: 'OK', properties: {name: 'ok'}}, \
              cncBtn: Button {text: 'Cancel', properties: {name: 'cancel'}}, \
           } \
      myDial = new Window(res);
      myDial.formField.active = true;
      function getName(){
          var name = myDial.formField.text;
          return name;
      if(myDial.show() == true){
          var myDoc = app.documents.add();
          var myPg = myDoc.pages.item(0);
          var myTxtFr = myPg.textFrames.add({geometricBounds:[50, 50, 100, 100], contents:getName()})
      else myDial.close()