Foundation > Rogue Wave Script Programming > Using Rogue Wave Script Callbacks
 
Using Rogue Wave Script Callbacks
Rogue Wave® Views gadgets are able to recognize specific mouse or keyboard events that apply to them and invoke the associated predefined Rogue Wave Script callback functions.
To handle gadget events using callbacks, you must:
*Write the callback functions: see Writing a Callback
*Set the callback: see Setting a Rogue Wave Script Callback
Writing a Callback
In Rogue Wave Script for Rogue Wave Views, callbacks have the following signature:
function CallBack(gadget, value)
Here is an example of a callback:
function OnButtonClick(button, value)
{
button.foreground = "red";
writeln("The additional value is: " + value);
}
The second argument passed to the callback is an optional value that you can specify when you set a callback in ivfstudio. The contents of the callback function can therefore be the following:
function OnGadgetClick(gadget)
{
gadget. foreground = "red";
}
Setting a Rogue Wave Script Callback
There are two ways to set a callback to a gadget:
*You can set callbacks in Rogue Wave Views Studio, while designing panels. This is the easiest way.
*You can set callbacks with the IlvGraphic::setCallback method. Using this method, you can set a callback to a gadget or modify it at run time. Here is an example:
myGadget.setCallback("Generic", "myCallback", "JvScript");
The first argument is the callback type that identifies the event to handle. The second argument is the callback function you defined. The third argument is always JvScript.

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.