Foundation > Rogue Wave Script Programming > Binding Rogue Wave Views Objects > Binding Rogue Wave Views Objects
 
Binding Rogue Wave Views Objects
To bind a Rogue Wave® 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. Rogue Wave 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 Rogue Wave 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 Rogue Wave Script through the Application symbol. Consequently, you can access the properties attached to Application from Rogue Wave Script:
var name = Application.name;
Accessing Rogue Wave Views Objects in Rogue Wave Script
You might want to bind all the Rogue Wave 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 Rogue Wave Views object starting from that object.
In a Rogue Wave Views application generated from ivfstudio, for example, you can access the pointers to the panels through the pointer to the application by calling the IlvApplication::getPanel method. Similarly, you can then access the gadgets in the panels by invoking the IlvContainer::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 Rogue Wave 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 Rogue Wave 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 Rogue Wave 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.

Version 6.3
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.