
Static text controls display text on property pages. Static text controls do not have to be associated with a parameter, but if you want, you can display the value of a String parameter as static text.
To add static text to a property page, use PPGLayout.AddStaticText or PPGLayout::AddStaticText.
function EmbeddedSynoptic_DefineLayout( ctxt )
{
var oLayout,oItem;
oLayout = ctxt.Source;
oLayout.Clear();
// UI text that explains how to use the synoptic view
oLayout.AddStaticText(
"Click the sphere to translate the object by the specified increment.\n" +
"Click the large cone to reset the translations."
0, // Use default width
0 // Use default height
);
return true;
}
PPGLayout.AddStaticText or PPGLayout::AddStaticText is a shortcut for calling PPGLayout.AddItem or PPGLayout::AddItem with the siControlStatic attribute:
// Use the name "Static" to display static text on the ppg // The second parameter, which usually specifies the label, is the static text oLayout.AddItem( "Static", "Static Text", siControlStatic ); oLayout.AddItem( "Static", "More Static Text", siControlStatic );
Static text does not word wrap when a user resized the property page, so you may want to specify a width and height in the call to PPGLayout.AddStaticText or PPGLayout::AddStaticText.
You access a static text control through the PPGLayout.Item or PPGLayout::GetItem property, which returns the PPGItem or PPGItem for the static text. To change the static text, set the PPGItem.Label or PPGItem::GetLabel or PPGItem::PutLabel property:
function EmbeddedSynoptic_OnInit( )
{
// The static text we want to display
// Use "\n" to insert a line break
var sUIText = "Click a sphere to translate " +
PPG.Inspected(0).Parent +
" by the specified increment.\n" +
"Click the large cone to reset the translations.";
// Set the static text
// Static text controls are named "Static"
PPG.PPGLayout.Item("Static").Label = sUIText;
// If you have more than one static text control,
// use the index number instead of the name "Static".
// The index numbers correspond to the order
// in which the controls were added to the layout.
// PPG.PPGLayout.Item(0).Label = sUIText;
}
If you want to display the value of a String parameter as static text, use PPGLayout.AddItem or PPGLayout::AddItem to add a static control for the parameter.
function MyProperty_Define( ctxt )
{
var oCustomProperty;
oCustomProperty = ctxt.Source;
oCustomProperty.AddParameter2("Param1",siString,"This is a Text parameter",null,null,null,null,0,siPersistable);
return true;
}
function MyProperty_DefineLayout( ctxt )
{
var oLayout;
oLayout = ctxt.Source;
oLayout.Clear();
// Add a static control for the string parameter Param1
// No label required: the control displays the parameter value
oLayout.AddItem( "Param1", "", siControlStatic );
return true;
}
Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License