C
HAPTER
2: Tutorial
Next steps
29
Playing action events
You also can play back action events from a plug-in. These action events could originate in the Illustrator
application or other plug-ins. The SnpDocumentActionHelper code snippet in the SnippetRunner plug-in
demonstrates how to play action events that originate in the Illustrator application.
Menu plug-ins
Illustrator allows plug-ins to add new menus to its menu structure. To add a menu, your plug-in must do
the following:
X
Call
AIMenuSuite::AddMenuItem
on start-up, to add the menu to Illustrator.
X
Optionally, call
AIMenuSuite::AddMenuGroupAsSubMenu
to create a group in which further menu
items can be nested.
X
Handle messages related to menu events. For example, when a plug-in’s menu item is clicked, the
plug-in is notified by a selector message (
kCallerAIMenu
/
kSelectorAIGoMenuItem
).
The Tutorial plug-in adds an About plug-in menu on start-up; see
“About Plug-ins menu” on page 19
. For
sample code, see the
AddMenu
function in
Tutorial.cpp
. A helper class,
SDKAboutBoxHelper
, is used to
create the menu that appears under Illustrator's About menu group. When it is used, Illustrator calls the
plug-in with the tool selectors listed above. The Tutorial plug-in’s
PluginMain
function handles this as
follows:
else if ( strcmp( caller, kCallerAIMenu ) == 0 ) {
if ( strcmp( selector, kSelectorAIGoMenuItem ) == 0 )
error = GoMenu( ( AIMenuMessage* )message );
}
When the menu is clicked, the Tutorial plug-in receives this selector and can process it. See the
GoMenu
function in
Tutorial.cpp
. This function pops an About box that displays contact details and a copyright
statement.
Next steps
To learn more about Illustrator plug-in programming, explore the samples provided in the SDK and the
documentation in
Adobe
Illustrator API Reference
. Instructions on running and debugging plug-ins are in
Getting Started with Adobe Illustrator CS5 Development
.