Event listener on page scroll

Explorer ,
Jun 28, 2022 Jun 28, 2022

Copy link to clipboard

Copied

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.
TOPICS
How to , Scripting

Views

96

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

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 )

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

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…

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

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.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

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-mer...

 

Regards,
Uwe Laubender
( Adobe Community Professional )

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 02, 2022 Jul 02, 2022

Copy link to clipboard

Copied

LATEST

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();

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines