3 Replies Latest reply on Feb 27, 2016 1:03 PM by TᴀW

    Progress bar from menu item problem?

    pontusuggla

      I have a script that creates a document with 50 pages while showing a progress bar in a palette window and it works fine.

       

      If I create a menu and run it from there the progress bar doesn´t update until the pages are created.

       

      I´ve had this problem for a really long time and it´s time to get this sorted out. The thing is that it used to work before an update long ago. It works on PC but not on mac.

       

      #targetengine "Testing"
      
      
      var test_menu = app.menus.item('$ID/Main').submenus.add('Test');
      var menu_item = app.scriptMenuActions.add('Create document...');
      
      
      menu_item.eventListeners.add('onInvoke', function()
      {
        app.documents.add();
      
      
        var w = new Window('palette');
        w.pbar = w.add('progressbar', undefined, 0, 50);
        w.pbar.preferredSize.width = 300;
        w.show();
      
      
        for( var i = 1; i <= 50; i++ )
        {
        w.pbar.value = i;
        app.activeDocument.pages.add();
        $.sleep(20);
        }
      });
      
      
      test_menu.menuItems.add( menu_item );