0 Replies Latest reply on Nov 10, 2016 1:55 PM by brandonl51082637

    Cancel or pause an invoked action to allow another action to complete

    brandonl51082637

      Hey all!

       

      I've been working on a seemingly simple script to force users to check spelling when they either save or export an indesign document.

       

      So far, I've managed to get the Spell Checking action to invoke before the save/export action takes place. This allows the Spell Checking dialog to popup before the save/export dialog.

       

      However, the issue I'm facing is that the save/export dialog pops up immediately after the function runs to pop up the spell checking dialog, so the user can't actually check spelling before saving or exporting.

       

      I'm thinking I need to only invoke the spell checking action when the document hasn't already been spell checked, and then tell the save/export action to cancel if the spell checking action needs to run, but I can't figure out the best way to script that.

       

      Any suggestions or kicks in the right direction would be greatly appreciated!

       

      Code so far:

       

      #targetengine "session"  
        
        
        
      main();  
        
      function main(){  
        
             alert('In Progress v12');     
        var
      
             beforeSave = app.menuActions.itemByName ( "$ID/Save" ).addEventListener ( "beforeInvoke", checkSpelling );
             beforeSaveAs = app.menuActions.itemByName ( "$ID/Save As..." ).addEventListener ( "beforeInvoke", checkSpelling );
             beforeSaveACopy = app.menuActions.itemByName ( "$ID/Save a Copy..." ).addEventListener ( "beforeInvoke", checkSpelling );
             beforeExport = app.menuActions.itemByName ( "$ID/Export..." ).addEventListener ( "beforeInvoke", checkSpelling );
         
        function checkSpelling(myEvent){  
             alert('Check Spelling...'); 
             app.menuActions.itemByName("Check Spelling...").invoke();  
        }
        
        
      }