/*
This example shows how to use Parameter.ReadOnly
*/
NewScene( null, false ) ;
var oProp = Application.ActiveSceneRoot.AddProperty( "CustomProperty",false,"Prop" ) ;
var oParam = oProp.AddParameter2( "ReadOnlyString", siString, null, null, null,
null, null, 0, siPersistable | siReadOnly ) ;
if ( !oParam.ReadOnly ) {
Application.LogMessage( "Expected readonly" ) ;
}
// Another way to test the same thing
if ( !(oParam.Capabilities && siReadOnly) ) {
Application.LogMessage( "Expected readonly" ) ;
}
// You can still change the value from scripting,
// but the user would not be able to modify this from a PPG.
oParam.Value = "A string" ;
//
// Show how the changing the read-only flag
// only affects the specific instance
//
// Copy inside a null
var oNull = Application.ActiveSceneRoot.AddNull() ;
CopyPaste( oProp, null, oNull, 2 ) ;
// Remove the readonly flag on the copy
var oProp2 = oNull.Properties( "Prop" ) ;
oProp2.Parameters("ReadOnlyString").ReadOnly = false ;
// Demonstrate that the original pset parameter is still read-only.
if ( !oParam.ReadOnly ) {
Application.LogMessage( "Expected still read-only" ) ;
}
// Show that the parameter is greyed out
InspectObj( oProp ) ;
// Expected result: <no messages are logged> |