I'm working on a plug-in that needs to check if the user is in isolation mode every time the layer list is changed. My plug-in needs to keep track of the all of the layers, but the layer list changes when the user enters isolation mode (double-clicks an element) and this messes up my plug-in. Here is my notifier method:
AIErr MyPlugin::LayerListChangedNotifier(AINotifierHandle notifier)
{
ASErr error;
AIDocumentHandle hCurrDoc = NULL;
long docCount;
AIIsolationModeSuite* sAIIsolationModeSuite = new AIIsolationModeSuite();
bool IsInIsolationModeBoolean = sAIIsolationModeSuite->IsInIsolationMode();
// Check if the user is in isolation mode.
if (IsInIsolationModeBoolean == true)
{
// If in isolation mode.
exit(1);
}
else
{
// If not in isolation mode.
exit(2);
}
return(kNoErr);
}
I've tested this method with other random code and am sure that it gets called correctly. It seems that with the code above, it seems to stop at:
bool IsInIsolationModeBoolean = sAIIsolationModeSuite->IsInIsolationMode();
Why would it stop at this point? It doesn't exit out or anything, it just simply stops at that line.
Any ideas?
Thanks in advance ![]()
This is just a stupid suggestion, but maybe throw an assert() on sAIIsolationModeSuite after its created, I assume you're running Windows -- I've never seen a Mac 'just stop', but I have seen Windows do that (no idea why). If hte sAIIsolationModeSuite is NULL after the new, I could see how that could cause it to die suddenly (even though you'd expect something more explicit). If not that, I'm not sure why else it would die there.
I've done some more testing and realized that while the method I was working in does get called, it only gets called when a new document is created, which means that I need to change my entire game plan.
Basically, what I need to do is be notified when the user enters into isolation mode so I can handle data accordingly. I'm actually fairly new to building Illustrator plug-ins, but not to C++ in general. I've found in the documentation that Illustrator sends out the kAIIsolationModeChangedNotifier when the user goes into isolation mode, but how would I go about catching this in Illustrator? Would I need to build a new method specifically for this?
I looked around the examples and didn't really see one that matched my situation, maybe I overlooked it?
Sorry for asking such a newbie question, but I am a bit more used to building with wxWidgets, etc. and got this project dropped in my lap from the previous developer with no one to turn to.
Thanks again! ![]()
Well, I've followed your advice and I think I'm getting somewhere (however slowly).
I've added a few lines to my main panel's notify method:
void MainPanel::Notify(IADMNotifier notifier)
{
BaseADMDialog::Notify(notifier);
ADMItemRef item = notifier.GetItem();
if (!item && notifier.IsNotifierType(kADMBoundsChangeNotifier))
{
this->ResizePanel(notifier);
}
// New code here, for detecting isolation mode.
if (notifier.IsNotifierType(kAIIsolationModeChangedNotifier))
{
printf("Isolation mode entered.");
}
else
{
printf("Not Isolation mode?");
}
}
Everything builds and runs correctly except for that it never seems to catch the kAIIsolationModeChangedNotifier. As this is a notify method attached to my main panel, it catches a lot of actions, but only ever outputs "Not Isolation mode?".
I take this as meaning that I have the right idea, but I'm no placing it in the right place to actually receive the kAIIsolationModeChangedNotifier. I figured the main panel's notifier would be perfect, but apparently it's not. Any ideas on where I can catch the kAIIsolationModeChangedNotifier?
Thanks again!
EDIT:
I've also tried adding a block of code that manually checks to see if Illustrator is currently in Isolation Mode or not, but it always crashes.
AIIsolationModeSuite* sAIIsolationModeSuite = new AIIsolationModeSuite();
printf("Instantiated sAIIsolationModeSuite.\n");
bool IsInIsolationModeBoolean = false;
printf("Created the IsInIsolationModeBoolean variable and set it to false.");
IsInIsolationModeBoolean = sAIIsolationModeSuite->IsInIsolationMode(); // Crashes here.
printf("Called the IsInIsolationMode() method.\n");
if (IsInIsolationModeBoolean == false)
{
printf("true");
}
else
{
printf("false");
}
It always crashes when I call the IsInIsolationMode() method. All of the printf statements up until that point display correctly, so I know that everything up until that method call is just fine. From what I could grasp from the documentation, the IsInIsolationMode() method only checks if Illustrator is currently in Isolation Mode or not and returns a boolean value. Why would it crash??
I don't really care if I use a notifier or manually check, as long as I can get it done.
You may have done this, but didn't mention it -- you need to register for a notifier before it will be sent to you. That's done with AINotifierSuite::AddNotifier().
As for the isoloation mode check, it may depend on how you're triggering that check. You might need an ApplicationContext object before you can perform that check, particularly if you're not doing it in direct response to some kind of caller/selector from Illustrator (i.e. a timer callback). You can't talk to the API without an ApplicationContext, though Illustrator does that for you if its in response to a caller/selector.
North America
Europe, Middle East and Africa
Asia Pacific