User Tools

Site Tools


DzCallBackMgr

Manager responsible for handling callback objects.

More...

Inherits :

Methods

Detailed Description

Responsible for the management of objects that are used to execute a script when a signal that the object is connected to is emitted.

There is only one instance of this manager in an application. This instance is created and owned by DzApp. Request the instance via DzApp::getCallBackMgr().

Example:

Dynamically load a script.

var sScript = "support/CallBackExample/HelloWorld.dsa";
var oCallBackMgr = App.getCallBackMgr();
var oCallBack = oCallBackMgr.createCallBack( "Hello World", sScript, false );
 
oCallBack.setConnection( Scene, "nodeAdded(DzNode*)" );

Example:

Embed a script.

var sPath = String( "%1/support/CallBackExample/HelloWorld.dsa" ).arg( App.getScriptsPath() );
var oScript = new DzScript;
oScript.loadFromFile( sPath );
var sScript = oScript.getCode();
 
var oCallBackMgr = App.getCallBackMgr();
var oCallBack = oCallBackMgr.createCallBack( "Hello World", sScript, true );
 
oCallBack.setConnection( Scene, "nodeAdded(DzNode*)" );

Example:

CallBack script (./support/CallBackExample/HelloWorld.dsa).

“CallBack” is a global transient variable referring to the DzCallBack that executes the script.

var oSender = CallBack.getSender();
var sMessage = String( "Sender Class: %1\n" +
		"Sender Name: %2\n\n" +
		"CallBack Args: %3" )
		.arg( oSender.className() )
		.arg( oSender.name )
		.arg( CallBack.getArgCount() );
 
var nArgs = CallBack.getArgCount();
if( nArgs > 0 ){
	for( var i = 0; i < nArgs; i += 1 ){
		sMessage += String( "\nArg %1 : %2" ).arg( i ).arg( CallBack.getArg( i ) );
	}
}
 
MessageBox.information( sMessage, CallBack.className(), "&OK" );

See Also:

Methods


void : clearAllCallBacks()

Deletes all callbacks.


DzCallBack : createCallBack( String name, String script, Boolean evaluate )

Creates a DzCallBack object.

Parameter(s):

  • name - The name for the callback.
  • script - The filename or code of the script to execute.
  • evaluate - If script is the actual code and it should be embedded, set this to true, otherwise it is assumed that script is the path of a script file to execute.

DzCallBack : createCallBack( String name )

Creates a DzCallBack object.

Parameter(s):

  • name - The name for the callback.

void : deleteCallBack( Number index )

Deletes the callback at the given index.

Parameter(s):

  • index - The index of the callback to delete.

void : deleteCallBack( String name )

Deletes all callbacks with the given name.

Parameter(s):

  • name - The name of the callback to delete.

void : deleteCallBack( DzCallBack callBack )

Deletes the specified callback.

Parameter(s):

  • callBack - The callback to delete.

void : deleteCallBackGroup( String name )

Deletes all callbacks in a given group.

Parameter(s):

  • name - The name of the group with callbacks to delete.

DzCallBack : getCallBack( Number index )

Return Value:

  • The callback at index if at least one callback exists and index is within the range [0, getNumCallBacks() - 1], otherwise null.

DzCallBack : getCallBack( String name )

Return Value:

  • The first DzCallBack object with the given name.

Number : getCallBackIndex( String name )

Return Value:

  • The index of the first callback named name.

Array : getCallBackList()

Return Value:

  • The list of all callbacks.

Array : getGroup( String name )

Return Value:

  • The list of callbacks in the group named name.

Number : getNumCallBacks()

Return Value:

  • The number of callbacks.

Array : getSignalSignature( QObject obj, String signalName=“” )

Return Value:

  • A list of strings that represent the signature(s) of the signal with the specified name.