0 Replies Latest reply on Oct 17, 2012 7:22 AM by MarkusVeith

    CS Extension: creating Popup with PopupManager does not work as expected (delayed)

    MarkusVeith Level 1

      Hi,

       

      i have some issues with a popup opening too late.

       

      In the following codeflow i have the issues that a popup is not showing up / opening when i call PopUpManager.createPopUp. There are also some InDesign actions started after calling createPopUp. The Popup seems to wait for the InDesign actions and only then is opening.

                                    model.m.win = PopUpManager.createPopUp(model.m, pm.layout.Dialog, true) as pm.layout.Dialog;
                                    PopUpManager.centerPopUp(model.m.win);
      // popup should be opened here
      ...further code...
      doc.exportFile(ExportFormat.PDF_TYPE,file);
      ...further code...
      doc.packageForPrint(...);
      // but popup opens here
      ...further code...
      
      

       

      model.m.win is of type TitleWindow

      and pm.layout.Dialog is a derivation of TitleWindow

       

      What am i doing wrong? Can i prevent indesign from blocking the extension until it finishes the actions?

      I already tried the methods

      invalidateDisplayList and

      validateNow

      Unfortunately they did not seem to have any effect. Same behaviour with and without those methods.

       

      Hope the explanation of my problem is understandable.

      Any help would be appreciated. Thanks in advance.

       

      Cheers,

           Markus Veith

       

      P.S.:

      Meanwhile i have written some test code that exactly shows what is not working correctly. What i wanted to achieve is a popup that shows the progress of the different steps i am doing to the document.

      For this it would be important to update the progress bar on every step. Unfortunately the popup is first shown at step 2/4 and then updated at step 4/4. So i do not see the progress on every step.

      // take active Document
                                                        doc = app.activeDocument;
                                                        model.m.win = PopUpManager.createPopUp(model.m, pm.layout.Dialog, true) as pm.layout.Dialog;
      // here popup should have been opened, but it is not shown until step 2/4
                                                        PopUpManager.centerPopUp(model.m.win);
                                                        model.m.win.prg.removeAllChildren();
                                                        model.m.win.message.text = "";
                                                        var pb:ProgressBar = new ProgressBar();
                                                        pb.mode="manual";
                                                        pb.label = "Package (%1/%2 bytes) (%3%%)";
                                                        pb.setActualSize(330,50);
                                                        pb.setProgress(1,4);
                                                        model.m.win.prg.addChild(pb);
      
                                                        var tmpDir:File = File.createTempDirectory();
                                                        var document_data_file:File = tmpDir.resolvePath(doc.name + ".dat");
                                                        var pdffile:File = tmpDir.resolvePath(doc.name + ".pdf");
                                                        var packagefile:File = tmpDir.resolvePath(doc.name);
                                                        var zipfile:File = tmpDir.resolvePath(doc.name + '.zip');
                                                        doc.exportFile(ExportFormat.PDF_TYPE,pdffile);
                                                        pb.setProgress(2,4);
      // here popup is first time shown with progress 2/4
                                                        var copyingFonts:Boolean = false;
                                                        var copyingLinkedGraphics:Boolean = true;
                                                        var copyingProfiles:Boolean = true;
                                                        var updatingGraphics:Boolean = true;
                                                        var includingHiddenLayers:Boolean = true;
                                                        var ignorePreflightErrors:Boolean = true;
                                                        var creatingReport:Boolean = true;
                                                        var versionComments:String = "comment";
                                                        var forceSave:Boolean = true;
                                                        doc.packageForPrint(
                                                                  packagefile, 
                                                                  copyingFonts, 
                                                                  copyingLinkedGraphics, 
                                                                  copyingProfiles, 
                                                                  updatingGraphics, 
                                                                  includingHiddenLayers,
                                                                  ignorePreflightErrors, 
                                                                  creatingReport, 
                                                                  versionComments,
                                                                  forceSave
                                                        );
                                                        pb.setProgress(3,4);
      // here progress bar should have been updated but it is not. It waits till step 4/4
                                                        var pmz:PMZip = new PMZip();
                                                        pmz.zipdir = packagefile;
                                                        pmz.zipfile = zipfile;
                                                        pmz.zipDir();
                                                        pb.setProgress(4,4);
      // here the progressbar is updated with 4/4
      

       

      My suspicion is that the 2 indesign actions doc.exportFile and doc.packageForPrint block the extension and updates only happen after those indesign actions are finished.

       

      Message was edited by: MarkusVeith