Skip to main content
Participant
October 18, 2011
Question

How to catch the event of applying color swatch to selected arts?

  • October 18, 2011
  • 1 reply
  • 726 views

Hi,all
   I want to know when the event occurs(applying color swatch to selected arts). I used kAIDocSwatchesSelectionChangedNotifier to catch the event. But

many actions would trigger kAIDocSwatchesSelectionChangedNotifier, like moving or

resizing art.So, how can i realize this? Thanks.

This topic has been closed for replies.

1 reply

A. Patterson
Inspiring
October 18, 2011

I'm surprised about kAIDocSwatchesSelectionChangedNotifier -- its supposed to just indicate that the user has clicked on a different one in the Swatch panel. I suppose that's not a bad one to listen to and then see if there's any selected art, since that would probably indicate it was applied. The only other notifier that would help you is kAIArtPropertiesChangedNotifier, but that's incredibly general. There's nothing more specific than what you're using now I believe.

whjwuAuthor
Participant
October 19, 2011

When the color of art is changed, these notifiers will be fired as follow:
1 kAIArtSelectionChangedNotifier
2 kAIDocSwatchesSelectionChangedNotifier
3 kAIArtPropertiesChangedNotifier
4 kAIAlignmentKeyArtChangedNotifier
5 kAIDocumentViewInvalidRectChangedNotifier

So,I did this:

if ( 0 == strcmp(message->type, kAIArtSelectionChangedNotifier) )
{
  notifyFlag |= 0x02;
  notifyFlag &= 3;
}
else if ( 0 == strcmp(message->type, kAIDocSwatchesSelectionChangedNotifier) )
{
  notifyFlag |= 0x04;   
  notifyFlag &= 7;
}
else if ( 0 == strcmp(message->type, kAIArtPropertiesChangedNotifier) )
{
  notifyFlag |= 0x08;   
  notifyFlag &= 15;
}
else if ( 0 == strcmp(message->type, kAIAlignmentKeyArtChangedNotifier) )
{
  notifyFlag |= 0x10;   
  notifyFlag &= 31;   
}
else if ( 0 == strcmp(message->type, kAIDocumentViewInvalidRectChangedNotifier) )
{
  notifyFlag |= 0x20;   
  notifyFlag &= 63;
  if (62 == notifyFlag)
   sADMBasic10->MessageAlert("U get it.");
}

But "U get it" is also showed when clicking other buttons on toolbar.