The application class represents a script application and is primarily reponsible for starting and stopping the script event loop. In event-oriented programming, the event loop drives the user interface aspects of the program, and coordinates the connection between the program code and the user's actions. Using the Application object allows the usage of Forms and interactive script programs.
// create an instance of our derived MyForm class
// and show it
var f = new MyForm;
f.show();
// start the event loop. At this point in the script, execution
// is turned over to the event loop, which the Application class manages.
// Execution will proceed from here only after Application.exit is called.
Application.run();
alert("This message appears after the event loop has exited.");
// our Form-derived class
class MyForm extends Form
{
function MyForm()
{
super("Hello World", 100, 100, 200, 100);
this.add(new Label("Click on the form to stop the application.",
5,5,100,100));
this.mouseLeftUp.connect(exitFunction);
}
}
function exitFunction()
{
// calling Application.exit() will terminate the event loop. Execution
// will continue in the same scope in which Application.run() was called
Application.exit();
}
Exists the event loop and stops the script from running.
Starts the event loop for a form. When using forms in a script, this function must be called before the form can register events.
Setting the shutdown style determines when the Application.run() function will exit. If a form is created before Application.run() is invoked, by default Application.run() will return to the caller when all forms are closed. Otherwise, Application.run() will only return once Application.exit() is called. Possible values are: Application.ShutdownOff and Application.ShutdownAfterAllFormsClose