0 Replies Latest reply on Apr 13, 2010 7:56 AM by Loic.Aigon

    Is it possible to remove user interaction in a eventListener ?

    Loic.Aigon Adobe Community Professional

      Hi,

       

      I am working on two scripts that both need to deal with the user interaction.

      This following script works just fine. The only matter is that Indesign alerts me that the script prevented the UI dialog from opening.

      What if I don't want any alert ?

       

      #targetengine "newdialog"
      
      Application.prototype.main = function(){
           //app.addEventListener ("beforeNew", preventMe, false);
           var myMenuAction = app.menuActions.item("$ID/Document...");
           myMenuAction.addEventListener ("beforeInvoke", preventMe, false)
      }
      
      function preventMe(myEvent){
           //alert(myEvent.cancelable);
           myEvent.stopPropagation();
           myEvent.preventDefault();
      }
      
      app.main();
      

       


      I thought about userInteractionLevel but I tried to use it recently and I couldn't get it working. My intention was to get an automated update of my modified links when opening a file.

      It's like

      app.scriptPreferences.userInteractionLevel

      couldn't be set once the script has been launched.

       

       

       

      #targetengine "autolinkupdate"
      main();
      function main(){
           var myMenuAction = app.menuActions.item("$ID/kPMOpenDocTextKey");
           myMenuAction.addEventListener("beforeInvoke",removeInteraction,false);
           //app.addEventListener("beforeOpen",removeInteraction, false);
           app.addEventListener("afterOpen",updatelinks, false);
      }
      function updatelinks(myEvent){
           
           var doc=myEvent.parent;
           var lk = doc.links;
           for(var i=0; i<lk.length; i++){
                try{
                     lk[i].update();
                }
                catch(e){}
           }
           app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
      }
      
      
      function removeInteraction(myEvent){
           app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
      }
      

       

       

      So my question is : Is it possible to remove user interaction in a eventListener ?

       

      Thanks,

       

      Loic