Skip to main content
Known Participant
June 29, 2022
Question

Event listener on page scroll

  • June 29, 2022
  • 3 replies
  • 297 views
I want to show the current page number in the panel. Is there any event listener available which is called on every page scroll, so that by calling it I can get the current page number..?
 
Thanks in advance.
This topic has been closed for replies.

3 replies

Community Expert
June 29, 2022

As already said: look into idle task.

Read into this thread here to see an example with idle task for a different purpose:

https://community.adobe.com/t5/indesign-discussions/need-assistance-creating-a-script-using-data-merge-info-to-adjust-varying-page-sizes/m-p/12593936#M457780

 

Regards,
Uwe Laubender
( Adobe Community Professional )

vnh68
Inspiring
July 2, 2022

I was also looking for such an event, but here is the best  I found. Scripts don't work well with events, and to create plugin is too expensive...

 

File name: displayedPage.jsx

#targetengine displayedPage
/**
    Put this file into "startup scripts" and reload ID.
    When you change active page the message about page number appears...
    However, the page becomes active only if a selection appears on it. 
    Unfortunately simple scrolling does not trigger an events.
*/
function displayedPage(){
    
    app.addEventListener('afterOpen', function(event){
        if (event.parent instanceof LayoutWindow) {
            
            var aDoc = app.activeDocument;
            var lWindow = event.parent;
            
            alert('Document name: ' + app.activeDocument.name);
            
            lWindow.addEventListener('afterAttributeChanged', function(wevent){
                var l_window = wevent.parent;
                alert("Displayed Page: " + l_window.activePage.name);
            });
                       
        }
    });

    /**
        This function is required, otherwise, the script will work even after deletion! 
    */
    app.addEventListener('beforeQuit', function(){
        app.eventListeners.everyItem().remove();
    });
}

displayedPage();

 

Community Expert
June 29, 2022

FWIW: If one scrolls through the layout window of a document one could see a change in page numbers in the normal GUI of InDesign. That's a control at the bottom of the layout window. If that is not reliable for you, my guess is, that a script could* could not be more precise…

 

Regards,
Uwe Laubender
( Adobe Community Professional )

 

[*] EDITED. My. Obviously I had not enough coffee this morning…

Hetal5C4CAuthor
Known Participant
June 29, 2022

Thanks @Laubender 

 

Page number shown at the bottom panel is reliable, but my client wants to see it in bigger view. So thinking to show it in the panel.

Can you please suggest which Constants/Event s I can attach with the layout window to get the active window page number.

 

Community Expert
June 29, 2022

Hi @Hetal5C4C ,

don't think, that's possible by scripting. At least not reliably.

What you can watch with an idle task are changes of the active spread or active page in the layout window.

But well, it could be that this would not correspond with the visible page or spread in the layout window.

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#LayoutWindow.html

 

Regards,
Uwe Laubender
( Adobe Community Professional )