Adobe 65061456 Programming Guide - Page 14
Notifiers, Handling callers and selectors, Message data
View all Adobe 65061456 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 14 highlights
CHAPTER 1: Overview Plug-in entry point and messages 14 your plug-in implements a preferences suite that other plug-ins use, they may call you in their shut-down handlers after you already shut down. Notifiers Some message actions also are referred to as notifiers, indicating something in Illustrator was changed by the user; for example, when the user selects an object. Plug-ins must register for the notifiers in which they are interested. The Notifier suite is used to register and remove notification requests (see AINotifierSuite). Plug-ins also can create their own notifiers, which can be used to broadcast changes to other plug-ins. Handling callers and selectors Your plug-in's organization is based largely on the messages it receives. The main routine of your plug-in must first determine the message action, using the caller and selector parameters. For example: extern "C" ASAPI ASErr PluginMain(char* caller, char* selector, void* message) { ASErr error = kNoErr; if ( strcmp( caller, kSPAccessCaller ) == 0 ) { // Handle Reload and Unload if ( strcmp( selector, kSPAccessReloadSelector ) == 0 ) error = MyRestoreGlobals( message ); else if ( strcmp( selector, kSPAccessUnloadSelector ) == 0 ) error = MySaveGlobals( message ); } else if ( strcmp( caller, kSPInterfaceCaller ) == 0 ) { // Handle Startup and Shutdown if ( strcmp( selector, kSPInterfaceStartupSelector ) == 0 ) error = MyStartupPlugin( message ); else if ( strcmp( selector, kSPInterfaceShutdownSelector ) == 0 ) error = MyShutdownPlugin( message ); } else if ( strcmp( caller, kCallerAIMenu ) == 0 && strcmp( selector, kSelectorAIGoMenuItem ) == 0 ) ){ // Handle menu message error = MyHandleMenu( message ); } return error; } Message data The last argument passed to your plug-in entry point is a pointer to a message data structure, which contains information appropriate to the message action. For example, when a mouse-clicked message action is received, the message data structure contains the mouse position. The contents of the message data structure depend on the message action and are not completely known until your plug-in identifies this. While the contents of the message data vary, by convention all message data structures begin with the common fields that are grouped into the SPMessageData structure: typedef struct SPMessageData { long SPCheck; struct SPPlugin *self; void *globals;