Search code examples
javascripteventsadobe-indesignextendscriptadobe-extension

Is it possible to detect the change of page in InDesign using CEP/ExtendScript/JS?


I'm currently creating a plugin on InDesign and I would like to know if it's possible to detect if the user changes page ?

I searched in the web and documentation, I found a few events but nothing that interests me.

I thought about storing the user's current page, detecting if there is a click event in the application in general (because there are several ways to switch pages) and retrieving the current page to do something like :

If (previousCurrentPage == newCurrentPage) { 
    alert('The user changed page !');
}

But I don't think it's possible to handle all page switching techniques.

So I would absolutely need to detect a user's page change.

Thanks in advance !

UPDATE

What I mean by page change is page change in the document on InDesign.

Here, the user is therefore on the 1st page of the document :

enter image description here

Here the user is on the 3rd page of the document:

enter image description here

It's this change of page that I would like to be able to recover via my plugin.


Solution

  • SOLUTION

    To get the index of the page, I make this line of code in ExtendScript :

    app.activeWindow.activePage.documentOffset;
    

    And to detect the page change, I have a setInterval() that is called every 700ms and calls the above code snippet.

    If the previous page is different from the current page, I enter my condition and set my current page as the previous one.