Object Hierarchy | 関連する C++クラス:MenuItem
MenuItem
v4.0
 MenuItem オブジェクトは、カスタムMenuの個々の項目です。MenuItem オブジェクトを使用すると、メニュー項目にコマンドまたはコールバック関数をアタッチでき、メニュー項目がクリックされたときに有効になります。
カスタム メニュー項目には、他に次のような機能があります。
 - コマンドが無効の場合、そのコマンドで設定されたメニュー項目は淡色表示されます。
 - メニュー項目によって、コマンドまたはコールバックの起点を示します(ユーザの場合は[u]、ワークグループの場合は[w])。
 - コマンドを呼び出すメニュー項目には、そのコマンドに関連付けられているホットキーを表示します。
 - Filterを使用してメニューを設定し、メニューを開く前に選択されたオブジェクトやターゲットオブジェクトを考慮してメニュー項目を評価します。フィルタ条件が満たされると、カスタムメニューは淡色表示されるか、表示されません。
 - 使用するコマンドまたはオブジェクトモデルメソッドがアンドゥおよびリドゥをサポートしている場合、コールバック関数でもアンドゥを使用できます。
メニュー項目とは、プログラマがコマンドまたはコールバック関数をアタッチできる標準的なメニュー項目であると定義できます(注:何らかの理由でメニュー項目にコマンドとコールバックを両方とも割り当てる場合、メニュー項目が選択されるとコマンドよりもコールバックが優先されます)。また、セパレータまたはサブメニューとしてメニュー項目を作成することもできます。カスタムメニューにメニュー項目を追加する方法の詳細については、Menuオブジェクトのマニュアルを参照してください。
| Application | Callback | Categories | Checked | 
| Command | Enabled | Filter | FullName 		 | 	
| Help | Name 		 | 		NestedObjects | Origin | 
| OriginPath | Parent | Style | Type 		 | 	
// JScript implementation example of a custom menu item 
// This function is required to register the menu in Softimage
//
// README: Copy and paste the example into the script editor 
// and run (F5).
//
// The menu will install itself into the main window menu
//-------------------------------------------------------------------
function  XSILoadPlugin( in_reg )
{
	// register plug-in information
	in_reg.Author = "Softimage Co." ;
	in_reg.Name = "MenuItem Example";
	//  the version number of this plug-in
	in_reg.Major = 1;
	in_reg.Minor = 0 ;
	// install a custom menu in the window menu 
	in_reg.RegisterMenu( siMenuMainWindowID, "ExMenuItem", true, true );
	return true;
}
// This is the callback function used for building the menu. Since the menu is
// dynamic, the function is called each time the menu opens.
function  ExMenuItem_Init( in_ctxt )	
{
	// retrieve the menu object to build 
	menu = in_ctxt.Source;
	// attach a menu item to the menu along with its function handler
	menu.AddCallbackItem( "Custom menu item", "OnMenuItem" );
	return true;
}
//This callback function is called by Softimage when the menu item is selected
function OnMenuItem( in_ctxt )
{
	var menuitem = in_ctxt.source;
	LogMessage( menuitem.name + ":" + menuitem.callback );
}
//--------------------------------------------------------------------
// Code to bootstrap example into system
//--------------------------------------------------------------------
function ExampleSourceCode()
{
	return "// XSISDK Doc Example\n" +	
		ExMenuItem_Init.toString() + "\n" + 
		OnMenuItem.toString() + "\n" + 
		XSILoadPlugin.toString();
}
// if we are running from script editor save code to 
// examples addon folder in the user's directory.
if (GetUserPref("ScriptingSessionActive"))
{
	var ex_name 	= "ExMenuItem";
	var ex_subfolder 	= "Plugins";
	var ex_folder 	= "XSISDKDocExamples";
	var ex_langsuffix	= ".js";
	CreateAddonDirectories( InstallationPath(siUserPath), ex_folder );
	var fso = XSIFactory.CreateActiveXObject("Scripting.FileSystemObject");
	var filename = XSIUtils.BuildPath( 
		InstallationPath(siUserAddonPath), 
		ex_folder,
		"Application",
		ex_subfolder,
		ex_name+ex_langsuffix );
	if (!fso.FileExists(filename))
	{
		var f = fso.CreateTextFile ( filename );
		f.write( ExampleSourceCode() );
		f.close();
		Application.LoadPlugin(filename);	
	}
}
// |