ダイナミック メニューの場合、このコールバックは、メニューがアクセスされるたびに発生します。 スタティック メニューの場合、このコールバックは、プラグインのロード後に初めてメニューがアクセスされると発生します。
ここで、メニューに項目とコマンドを追加します。
public class <menu_name>
{
public bool Init( Context in_context )
{
...
}
} |
CStatus <menu_name>_Init( CRef& in_context )
{
...
} |
function <menu_name>_Init( in_context )
{
...
} |
def <menu_name>_Init( in_context ): ... |
Function <menu_name>_Init( in_context ) ... End Function |
sub <menu_name>_Init
{
my $in_context = shift;
} |
<menu_name> は、PluginRegistrar.RegisterMenu の呼び出しで指定されている名前です。この名前に含まれるスペースはアンダースコアに置き換えられます。
| パラメータ | 言語 | タイプ | 説明 |
|---|---|---|---|
| in_context | スクリプティングおよび C# | コンテキスト | Context.Source は Menu を返します。 |
| C++ | CRef& | Context オブジェクトへのリファレンス。 Context::GetSource は Menu を返します。 |
// JScript code generated by the Command Wizard
// Shows the Init callbacks for a command and for a menu
function XSILoadPlugin( in_reg )
{
in_reg.Author = "sblair";
in_reg.Name = "MyCommandPlugin";
in_reg.Email = "";
in_reg.URL = "";
in_reg.Major = 1;
in_reg.Minor = 0;
in_reg.RegisterCommand("MyCommand","MyCommand");
in_reg.RegisterMenu(siMenuTbGetPropertyID,"MyCommand_Menu",false,false);
//RegistrationInsertionPoint - do not remove this line
return true;
}
function XSIUnloadPlugin( in_reg )
{
strPluginName = in_reg.Name;
Application.LogMessage(strPluginName + " has been unloaded.");
return true;
}
function MyCommand_Init( ctxt )
{
var oCmd;
oCmd = ctxt.Source;
oCmd.Description = "";
oCmd.ReturnValue = true;
var oArgs;
oArgs = oCmd.Arguments;
oArgs.Add("Arg0",siArgumentInput);
return true;
}
function MyCommand_Execute( Arg0 )
{
Application.LogMessage("MyCommand_Execute called");
//
// TODO: Put your command implementation here.
//
return true;
}
function MyCommand_Menu_Init( ctxt )
{
var oMenu;
oMenu = ctxt.Source;
oMenu.AddCommandItem("Run My Command","MyCommand");
return true;
} |
// C++ code generated by the Command Wizard
// Shows the Init callbacks for a command and a menu
#include <xsi_application.h>
#include <xsi_context.h>
#include <xsi_pluginregistrar.h>
#include <xsi_status.h>
#include <xsi_argument.h>
#include <xsi_command.h>
#include <xsi_menu.h>
using namespace XSI;
SICALLBACK XSILoadPlugin( PluginRegistrar& in_reg )
{
in_reg.PutAuthor(L"sblair");
in_reg.PutName(L"My_CppCommandPlugin");
in_reg.PutEmail(L"");
in_reg.PutURL(L"");
in_reg.PutVersion(1,0);
in_reg.RegisterCommand(L"My_CppCommand",L"My_CppCommand1");
in_reg.RegisterMenu(siMenuTbGetPropertyID,L"My_CppCommand_Menu",false,false);
//RegistrationInsertionPoint - do not remove this line
return CStatus::OK;
}
SICALLBACK XSIUnloadPlugin( const PluginRegistrar& in_reg )
{
CString strPluginName = in_reg.GetName();
Application().LogMessage(strPluginName + L" has been unloaded.");
return CStatus::OK;
}
SICALLBACK My_CppCommand_Init( CRef& in_ctxt )
{
Context ctxt( in_ctxt );
Command oCmd;
oCmd = ctxt.GetSource();
oCmd.PutDescription(L"");
oCmd.EnableReturnValue(true);
ArgumentArray oArgs;
oArgs = oCmd.GetArguments();
oArgs.Add(L"Arg0");
return CStatus::OK;
}
SICALLBACK My_CppCommand_Execute( CRef& in_ctxt )
{
Context ctxt( in_ctxt );
CValueArray args = ctxt.GetAttribute(L"Arguments");
CValue Arg0 = args[0];
Application().LogMessage(L"My_CppCommand_Execute called");
//
// TODO: Put your command implementation here.
//
// Return a value by setting this attribute:
ctxt.PutAttribute( L"ReturnValue", true );
// Return CStatus::Fail if you want to raise a script error
return CStatus::OK;
}
SICALLBACK My_CppCommand_Menu_Init( CRef& in_ctxt )
{
Context ctxt( in_ctxt );
Menu oMenu;
oMenu = ctxt.GetSource();
MenuItem oNewItem;
oMenu.AddCommandItem(L"My_CppCommand",L"My_CppCommand",oNewItem);
return CStatus::OK;
} |