Skip to main content
April 30, 2012
Answered

How to get notification when any master spread is set to active from InDesign

  • April 30, 2012
  • 1 reply
  • 1147 views

Hi all,

I need to get notified when any master spread is selected from InDesign or pages are inserted/deleted from any master spread.

For this, I have implemented a custom observer derived from CObserver.

In AutoAttach(), the code is as follows,

        InterfacePtr<IWorkspace> docWorkspace(doc->GetDocWorkSpace(), UseDefaultIID());

        if( !docWorkspace )

            break;

        InterfacePtr<ISubject> docSubject(docWorkspace, UseDefaultIID());

        if( !docSubject )

            break;

        docSubject->AttachObserver(this, IID_ISPREADLIST, IID_IABCDOCOBSERVER);

        docSubject->AttachObserver(this, IID_ICURRENTSPREAD, IID_IABCDOCOBSERVER);

        docSubject->AttachObserver(this, IID_IMASTERSPREADLIST, IID_IABCDOCOBSERVER);

        docSubject->AttachObserver(this, IID_IPAGEPREFERENCES, IID_IABCDOCOBSERVER);

I have observed these protocols but still don't get any notification when any spread is selected (set to active spread) or pages are added in any master spread.

Please let me know which interface should be observed to get notified for the same? Am I correct in checking the document workspace as subject?

Please help me out. Thanks in advance.

This topic has been closed for replies.
Correct answer Suraba

Daves61,
I need to clarify what kind of event you're interested in.

1. When you click once on page/spead widget in the Pages panel and only widget becomes selected. The layout window remains unchanged. OR

2. When you doubleclick on page/spread widget the selected master spread appears in the layout window.

In the first case you work with Pages panel.

Have a look to file PageTransitionsPanelObserver.cpp from SDK. 
PageTransitionsPanelObserver::LazyUpdate()

In the second case you work with Layout window.

1 reply

Inspiring
May 3, 2012

Shortly:

Even if the method AutoAttach exists, it doesn't imply it will call automatically. You should call AutoAttach yourself.
You need also e.g. a responder service (maybe Startup/Shutdown) from where you will call all AutoAttach methods of your observers.

It is better to AddIn your IID_IABCDOCOBSERVER to existing boss-class (kWorkspaceBoss or kDocumentBoss).

May 3, 2012

Thanks for replying Suraba.

I have already created my custom observer, IID_IABCDOCOBSERVER and added it in my dialog's class. I'm calling its Auto-attach whenever my plugin is opened. I'm already using this for observing GridPreferences, PagePreferences etc. This works fine for them.

Now I have to observe the change in active spread & still looking for the solution.

Suppose there are 3 master spreads on any document, ABC-1, ABC-2, ABC-3.

ABC-1 is the currently active spread. Now, if I select ABC-2 from InDesign, I want to get its notificaiton. Plz help me out.

SurabaCorrect answer
Inspiring
May 3, 2012

Daves61,
I need to clarify what kind of event you're interested in.

1. When you click once on page/spead widget in the Pages panel and only widget becomes selected. The layout window remains unchanged. OR

2. When you doubleclick on page/spread widget the selected master spread appears in the layout window.

In the first case you work with Pages panel.

Have a look to file PageTransitionsPanelObserver.cpp from SDK. 
PageTransitionsPanelObserver::LazyUpdate()

In the second case you work with Layout window.