Binding Views Objects
To bind a Views object, call the following function:
IlvScriptContext::bind(IlvValueInterface* object,
const char* name);
This function takes a pointer to the object to be bound as its first parameter and the character string to which the object is bound as its second parameter. Script programmers can use this name to access the associated object. The pointer is of the type IlvValueInterface, which is a superclass for most of the Views classes.
Thus, you can bind an IlvApplication object with the following code:
IlvScriptLanguage* jvscript = IlvScriptLanguage::Get("JvScript);
IlvScriptContext* theContext = jvscript->getGlobalContext();
theContext->bind(theApp, "Application");
// theApp is the pointer to an IlvApplication
The above code binds the IlvApplication object to Script through the Application symbol. Consequently, you can access the properties attached to Application from Script:
var name = Application.name;
Accessing Views Objects in Script
You might want to bind all the Views objects in your application. To do so, the best solution is to bind only the root object. This is because you can access, either directly or indirectly, almost any other Views object starting from that object.
In a Views application generated from ivfstudio, for example, you can access the pointers to the panels through the pointer to the application by calling the getPanel method. Similarly, you can then access the gadgets in the panels by invoking the getObject method. This is the reason why, in such applications, the only object that should be bound is an IlvApplication object.
The Application Object
In applications generated with ivfstudio, the IlvApplication object is bound with the Application symbol. You can access any other Views object starting from the Application object.
Let us suppose that your application contains one panel named myPanel. Here is how you can access it in Script:
var panel = Application.getPanel("myPanel");
To change its title, you can type:
panel.title = "New title";
If the panel in your application contains one button called myButton, you can access it using the following code:
var button = panel.getObject("myButton");
To change the button label, type:
button.label = "A new label";
Accessing Panels and Gadgets
Below are easier ways to access an application’s panels and gadgets.
To access the panel named myPanel in Script, you can type:
var panel = Application.myPanel;
To change its title:
Application.myPanel.title = "A new title";
To access gadgets in the panel:
var button = panel.myButton;
Note that only panels and gadgets that have regular names can be accessed that way. If a panel or gadget name includes special characters, such as &, +, -, =, space, and so on, you will not be able to access them using the procedures described above. Be careful not to use these characters in the name of panels and gadgets.