5 Replies Latest reply on Apr 19, 2012 1:06 AM by Peter Kahrel

    ScriptUI palette doesn't display when created inside an event listener

    Peter Kahrel Adobe Community Professional & MVP

      The script below creates a script menu action, adds an item to InDesign's Window menu, which, when selected, invokes an event listener. This listener in turn creates a ScriptUI palette if necessary and shows it. But the problem is that the palette isn't shown. When I create a dialog instead of a palette it works fine. And if I first create the palette in a separate script, close it, and then run the below script, everything works as expected (the palette is shown). It looks as if I don't understand some interaction between target engines, event listeners, and palettes. Hope anyone can enlighten me.

       

      Thanks,

       

      Peter

       

       

      #target indesign;
      #targetengine "Grrrr";
      
      var utils = app.menus.item("Main").menuElements.item("Window").menuElements.item("Utilities");
      var sma = app.scriptMenuActions.add("No break");
      
      sma.addEventListener('onInvoke',
          function()
              {
              var w = Window.find ('palette', 'NoBreak');
              if (w == null)
                  {
                  var w = new Window ('palette', 'NoBreak')
                      w.orientation = "row";
                      w.add ('statictext', undefined, "+/\u2212");
                      w.add ('statictext', undefined, "No break");
                  }
              w.show();
              }
          );
      
      app.menus.item("$ID/Main").submenus.item("$ID/&Window").menuItems.add(sma, LocationOptions.after, utils);