I need to modify the behavior of a secondary process I launch in my plugin when the InDesign app hides (from the dock or using the cmd+h key combination).
I was trying to add an observer and callback using the Notification Center (local) though I can't find a way to get the main or key window to do so.
Anyone has any pointers as how I can do this?
I'm not sure what you mean with Notification Center (local).
Sounds like an OSX specific thing.
Instead, attach an InDesign IObserver to the kAppBoss, protocol IID_IAPPLICATION.
You'll receive kApplicationSuspendMsg and kApplicationResumeMsg.
I only receive the kApplicationSuspendMsg (InDesign CS3), what could I be missing?
In the startupshutdown i have:
obsv = (IObserver*) CreateObject (kAppObserverBoss, IID_IOBSERVER);
//attach app messages observer
InterfacePtr<IApplication> iApp (gSession->QueryApplication ());
InterfacePtr<ISubject> iAppSubject (iApp, IID_ISUBJECT);
iAppSubject->AttachObserver(obsv , IID_IAPPLICATION);
and in the update of the appObserver I have:
if( theChange.Get ()== kAppBoss)
I have another problem, I think what I need instead is to make my secondary process (with gUI) nest as a child window to indesign's main window, because if I try to use this messages, I'll always receive them when I change focus to the separate window.
As Dirk rightly pointed out, you need to place an observer in the kAppBoss and observe on the IID_IAPPLICATION protocol.
What you should do is just place an interface as an addin in the kAppBoss and give it an implementation (you don't need to create a observer boss class as you have done).
In startup call the autoattach of your observer, for ex
InterfacePtr<IObserver> iMyObserver(app, IID_IMYOBSERVER);
In the autoattach method of your implementation class, remember to pass your observers interface ID to the attachobsever method of the ISubject
AttachObserver(this, IID_IAPPLICATION, IID_IMYPOBSERVER);
Then in the update method you will get properly notified of the suspend and resume of application
This should fix your problem.
- Efficient InDesign Solutions -