Hi!
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?
Thanks!
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);
if(iAppSubject)
iAppSubject->AttachObserver(obsv , IID_IAPPLICATION);
and in the update of the appObserver I have:
do {
if( theChange.Get ()== kAppBoss)
{
if(protocol.Get()==IID_IAPPLICATION){
if(theChange==kApplicationSuspendMsg){
fprintf(stderr, "kApplicationSuspendMsg\n");
}
if(theChange==kApplicationResumeMsg){
fprintf(stderr, "kApplicationResumeMsg\n");
}
}
}
}while(kFalse);
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<IApplication> app(gSession->QueryApplication());
InterfacePtr<IObserver> iMyObserver(app, IID_IMYOBSERVER);
iMyObserver->AutoAttach();
In the autoattach method of your implementation class, remember to pass your observers interface ID to the attachobsever method of the ISubject
for ex
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.
Manan Joshi
- Efficient InDesign Solutions -
MetaDesign Solutions
http://metadesignsolutions.com/services/indesign-development.php
North America
Europe, Middle East and Africa
Asia Pacific