## PPG.Close

### Introduced

v4.0

### Description

Forces the PPG to close itself. This can be useful for simulating pseudo-modal behavior in a Property Page without actually using the siModal argument to InspectObj.

### Scripting Syntax

    PPG.Close();

### Examples

#### JScript Example

    // Jscript example of a pseudo-modal, self-destructive

    // property page.

    //

    // In cases where a fully modal dialog box isn't suitable

    // you can accomplish a very similar feature

    ClosePPGDemo() ;

    function ClosePPGDemo()

    {

    	newscene( null, false ) ;

    	var oPSet = ActiveSceneRoot.AddCustomProperty(

    					"CloseDemo",

    					false ) ;

    	oPSet.AddParameter3( "MyValue", siInt4 ) ;

    	oPSet.AddParameter3( "Pickedobj", siString ) ;

    	var oPPGLayout = oPSet.PPGLayout ;

    	oPPGLayout.AddItem( "MyValue" ) ;

    	oPPGLayout.AddGroup( "Picked Object" )

    	oPPGLayout.AddRow() ;

    	var oPPGItem = oPPGLayout.AddItem( "Pickedobj" ) ;

    	oPPGItem.SetAttribute( siUINoLabel, true ) ;

    	oPPGItem = oPPGLayout.AddButton( "Pick", "Pick..." ) ;

    	oPPGItem.WidthPercentage = 10 ;

    	oPPGLayout.EndRow() ;

    	oPPGLayout.EndGroup() ;

    	oPPGLayout.AddRow();

    	oPPGLayout.AddButton( "OK" ) ;

    	oPPGLayout.AddButton( "Cancel" ) ;

    	oPPGLayout.EndRow();

    	oPPGLayout.Language = "JScript" ;

    	oPPGLayout.SetAttribute( "LogicPrefix", "CloseDemo_" ) ;

    	oPPGLayout.Logic = CloseDemo_OK_OnClicked.toString() +

    		CloseDemo_Cancel_OnClicked.toString() +

    		CloseDemo_Pick_OnClicked.toString() ;

    	// Pop up the Propery Page.

    	// It is not modal, but will clean itself up

    	InspectObj( oPSet ) ;

    	// Because the dialog is not modal

    	// the script will continue to execute here

    	// immediately, even before the Custom Property

    	// page has a change to appear.  Be careful not

    	// to assume the user has already made some selection

    	// and dismissed the dialog.  instead we leave it

    	// for the Spdl logic callback to complete whatever

    	// work we are trying to accomplish

    	Logmessage( "After InspectObj call" ) ;

    }

    // TIP: neither of these callbacks will get called if the

    // user closes the dialog using the "X".  These only get

    // called if the specific OK and Cancel buttons are clicked.

    function CloseDemo_OK_OnClicked()

    {

    	if ( PPG.PickedObj == "" )

    	{

    		// Example of doing some validation

    		// before allowing the user to

    		// proceed

    		XSIUIToolkit.MsgBox( "Please pick an object first" ) ;

    		return ;

    	}

    	// Here is where you would do something

    	// based on the values in the property page

    	Logmessage( "User clicked OK with value: " + PPG.MyValue ) ;

    	// Cleanup:

    	// Delete the object from right beneath us

    	DeleteObj( PPG.Inspected.Item(0) ) ;

    	// Clearly it would not be safe to make any further

    	// Object Model calls now that our object has been

    	// deleted

    	// However rather than leaving an empty frame

    	// we can close the whole window

    	PPG.Close() ;

    }

    function CloseDemo_Cancel_OnClicked()

    {

    	// Same as OK, but don't do any action

    	DeleteObj( PPG.Inspected.Item(0) ) ;

    	PPG.Close() ;

    }

    function CloseDemo_Pick_OnClicked()

    {

    	// The PickObject command is a good candidate for

    	// a pseudo-modal dialog, because it

    	// does not work in modal dialogs.

    	// PickObject returns multiple arguments

    	var aRtn = PickObject( "Select Object", "Select Object" )

    	var buttonChoice = aRtn.Value( "ButtonPressed" ) ;

    	if ( buttonChoice != 0 )

    	{

    		PPG.PickedObj.Value = aRtn.Value( "PickedElement" ) ;

    	}

    }

    // Typical results of running this script:

    //

    //INFO : "After InspectObj call"

    //INFO : "User clicked OK with value: 43"

### See Also

InspectObj DeleteObj