//************************************************************************************** // Filename: EmptyCM.cp // Part of Contextual Menu Workshop by Abracode Inc. // http://free.abracode.com/cmworkshop/ // Copyright © 2002-2003 Abracode, Inc. All rights reserved. // // Description: sample CM Plugin implementation // //************************************************************************************** #include "CFAbstractCMPlugin.h" #include "CMUtils.h" #include "DebugSettings.h" // --------------------------------------------------------------------------- // CMPluginExamineContext // --------------------------------------------------------------------------- // Have a look at the selection and decides whether to display any commands OSStatus CMPluginExamineContext( void *thisInstance, const AEDesc *inContext, AEDescList *outCommandPairs ) { TRACE_STR( "\pEmptyCM->CMPluginExamineContext" ); AbstractCMPluginType *theThis = (AbstractCMPluginType *)thisInstance; if(inContext == NULL) return errAENotAEDesc; #if _DEBUG_ //If you compile this plug-in in debug mode and install it //you can open the Console application and ctrl-click around in any application //on any object to see what data type is actually available to contextual menu plug-ins Str31 debugStr; DEBUG_STR( "\pCMPluginExamineContext: available data type is:" ); UInt8 *descPtr = (UInt8 *)&(inContext->descriptorType); debugStr[0] = 4; debugStr[1] = descPtr[0]; debugStr[2] = descPtr[1]; debugStr[3] = descPtr[2]; debugStr[4] = descPtr[3]; DEBUG_STR( debugStr ); #endif //If type is typeNull then there is no available context data from the host. //However, some plug-ins might want to get the context data //from the application in some other way or may want to display its menu ALWAYS /* if(inContext->descriptorType == typeNull) { return errAENotAEDesc; } */ if( true /*check your context here*/ ) { //add menus and/or submenus here CMUtils::AddCommandToAEDescList( "\pEmptyCM: Sample Menu", kCMImplCommand, outCommandPairs ); } return noErr; } // --------------------------------------------------------------------------- // CMPluginHandleSelection // --------------------------------------------------------------------------- // Carry out the command that the user selected. The commandID indicates // which command was selected OSStatus CMPluginHandleSelection( void *thisInstance, AEDesc *inContext, SInt32 inCommandID ) { TRACE_STR( "\pEmptyCM->CMPluginHandleSelection" ); AbstractCMPluginType *theThis = (AbstractCMPluginType *)thisInstance; if(inCommandID == kCMImplCommand) { //do something useful here } return noErr; } // --------------------------------------------------------------------------- // CMPluginPostMenuCleanup // --------------------------------------------------------------------------- void CMPluginPostMenuCleanup( void *thisInstance ) { TRACE_STR( "\pEmptyCM->CMPluginPostMenuCleanup" ); AbstractCMPluginType *theThis = (AbstractCMPluginType *)thisInstance; }