このコールバックは、ユーザがプロパティ ページを操作するときに発生します。
このコールバックを使って、プロパティ ページ上のユーザ インターフェイスのイベントを処理します。 このコールバックは、ユーザが次のいずれかの操作を行うと発生します。
また、このコールバックは、プロパティ ページを開いたり、パラメータ値を変更するスクリプト コードによってトリガーされることもあります。
| 警告: | このコールバックは、C# のみのオブジェクト モデルで使用できます。 スクリプトには、オブジェクト モデルの各 PPG イベントに個別のコールバックがあります。 スクリプト コールバックには入力引数がないため、代わりにグローバル PPG オブジェクトを使用することで、プロパティ ページのコントロールとレイアウトにアクセスできます。 |
C++ および C# のカスタム プロパティ
public class <property_name>
{
public bool PPGEvent( Context in_context )
{
...
}
} |
CStatus <property_name>_PPGEvent( CRef& in_context )
{
...
} |
<property_name> は、PluginRegistrar.RegisterProperty の呼び出しで指定されている名前です。この名前に含まれるスペースはアンダースコアに置き換えられます。 たとえば、My Property という名前のプロパティを登録する場合、コールバック関数の名前の先頭は My_Property になります。
| パラメータ | Language | タイプ | 説明 |
|---|---|---|---|
| in_context | C# | PPGEventContext | PPGEventContext オブジェクト。 PPGEventContext.EventID は、コールバックをトリガーしたイベントを識別します。 siOnInit、siOnClose、siTabChange、および siButtonClicked イベントの場合、PPGEventContext.Source は CustomProperty を返します。 siParameterChange イベントの場合、PPGEventContext.Source は Parameter オブジェクトを返します。 CustomProperty を取得するには、Parameter の SIObject.Parent プロパティを呼び出します。 |
| C++ | CRef& | PPGEventContext へのリファレンス。 PPGEventContext::GetEventID は、コールバックをトリガーしたイベントを識別します。 siOnInit、siOnClose、siTabChange、および siButtonClicked イベントの場合、PPGEventContext::GetSource は CustomProperty を返します。 siParameterChange イベントの場合、PPGEventContext::GetSource は Parameter オブジェクトを返します。 Parameter::GetParent から CustomProperty を取得できます。 |
| Attribute | 詳細 |
|---|---|
| Button | siButtonClicked イベントの場合、クリックされたボタンの名前を指定します。 |
| Close | True に設定すると、プロパティ ページは強制的に閉じます。 |
| Refresh | True に設定すると、プロパティ ページのレイアウトは強制的に更新されます。 |
| Tab | siTabChange イベントの場合、クリックされたタブの名前を指定します。 |
// PPGEvent callback generated by the Custom Property Wizard
SICALLBACK MyCppProperty_PPGEvent( const CRef& in_ctxt )
{
// This callback is called when events happen in the user interface
// This is where you implement the "logic" code.
// If the value of a parameter changes but the UI is not shown then this
// code will not execute. Also this code is not re-entrant, so any changes
// to parameters inside this code will not result in further calls to this function
Application app ;
// The context object is used to determine exactly what happened
// We don't use the same "PPG" object that is used from Script-based logic code
// but through the C++ API we can achieve exactly the same functionality.
PPGEventContext ctxt( in_ctxt ) ;
PPGEventContext::PPGEvent eventID = ctxt.GetEventID() ;
if ( eventID == PPGEventContext::siOnInit )
{
// This event meant that the UI was just created.
// It gives us a chance to set some parameter values.
// We could even change the layout completely at this point.
// For this event Source() of the event is the CustomProperty object
CustomProperty prop = ctxt.GetSource() ;
app.LogMessage( L"OnInit called for " + prop.GetFullName() ) ;
/* If you regenerate the layout then call this:
ctxt.PutAttribute(L"Refresh",true);
*/
}
else if ( eventID == PPGEventContext::siOnClose )
{
// This event meant that the UI was just closed by the user.
// For this event Source() of the event is the CustomProperty object
CustomProperty prop = ctxt.GetSource() ;
app.LogMessage( L"OnClose called for " + prop.GetFullName() ) ;
}
else if ( eventID == PPGEventContext::siButtonClicked )
{
// If there are multiple buttons
// we can use this attribute to figure out which one was clicked.
CValue buttonPressed = ctxt.GetAttribute( L"Button" ) ;
app.LogMessage( L"Button pressed: " + buttonPressed.GetAsText() ) ;
}
else if ( eventID == PPGEventContext::siTabChange )
{
// We will be called when the PPG is first opened
// and every time the tab changes
// Retrieve the label of the tab that is now active
CValue tabLabel = ctxt.GetAttribute( L"Tab" ) ;
app.LogMessage( L"Tab changed to: " + tabLabel .GetAsText() ) ;
}
else if ( eventID == PPGEventContext::siParameterChange )
{
// For this event the Source of the event is the parameter
// itself
Parameter changed = ctxt.GetSource() ;
CustomProperty prop = changed.GetParent() ;
CString paramName = changed.GetScriptName() ;
app.LogMessage( L"Parameter Changed: " + paramName ) ;
}
return CStatus::OK ;
} |