
C
HAPTER
2: Tutorial
Plug-in type-specific messages
28
X
Call
AIActionManagerSuite::AIDeleteActionParamType
to dispose of the TPB.
For sample code, see the
AddAction
function in
Tutorial.cpp
.
Recording action events
During your plug-in’s execution, if the user is in record mode, you are responsible for recording any action
events you registered. Illustrator is in record mode when the user is recording actions via the Actions
panel.
To record an action, your plug-in must do the following:
X
Call
AIActionManagerSuite::InRecordMode
to check if actions are being recorded.
X
Call
AIActionManagerSuite::AINewActionParamValue
to create a Value Parameter Block (VPB) in
which parameter values are recorded. A VPB is different from a TPB, in that it can contain actual values.
A TPB can contain only data type descriptions.
X
Populate the VPB with key value pairs that give the name and value of each parameter, by calling the
appropriate AIActionManagerSuite function for the type of data stored in the parameter. See
AIActionManagerSuite::AIActionSetBoolean
,
AIActionManagerSuite::AIActionSetInteger
,
etc.
X
Call
AIActionManagerSuite::
RecordActionEvent
to record the action event.
X
Call
AIActionManagerSuite::AIDeleteActionParamValue
to dispose of your reference to the VPB.
For sample code, see the
GoFilter
and
RecordFilterAction
functions in
Tutorial.cpp
.
Responding to the DoAction selector
To execute an action, your plug-in must handle the do-action selector pair (
kActionCaller
/
kDoActionSelector
) for each action event the plug-in registers. This is Illustrator’s way of requesting that
a particular action event be executed.
Your plug-in must add code for detecting such a notification. The Tutorial plug-in’s
PluginMain
function
handles the action selector, as follows:
else if ( strcmp( caller, kActionCaller ) == 0 ) {
if ( strcmp( selector, kDoActionSelector ) == 0 )
error = DoAction( ( DoActionMessage* )message );
}
The
DoAction
function in
Tutorial.cpp
executes the requested action event. The message struct sent
along with the
kDoActionSelector
is
DoActionMessage
. Documentation for this structure is in
Adobe
Illustrator API Reference
. It contains the recorded parameter values the action must replay. The
DoAction
function extracts the parameter values into its own data structure. The
DoActionMessage
struct also
indicates whether a dialog should be popped to allow the user to tune the parameter values before the
action is executed. The
DoAction
function responds accordingly, then calls the Tutorial plug-in’s filter
function,
GoFilter
, to re-play the action.