Introduction
The GUI module ports the widgets of wxWidgets to JavaScript.
wxTheApp
Unlike wxWidgets, there's no application class that derives from wxApp. The wxJavaScript console program instantiates an object of the type wxApp and stores it in the global variable wxTheApp. The application can be initialized assigning a function to the onInit event (Allthough it can also be initialized without this function). This function must create a top-level window and make that window visible. When the return value of this function is false, or there is no top-level window created, or the top-level window is invisible, the main loop will exit immediately. A simple example:
wxTheApp.onInit = init;
function init()
{
var frame = new wxFrame(null, -1, "A wxApp example");
// Don't forget to show the frame by setting
// the visible property to true!
frame.visible = true;
this.topWindow = frame;
return true;
}Event Handling
Event handling is simple in JavaScript. The only thing that is needed, is assigning a function to a predefined event property. For example: onKeyDown can be used to react on a pressed key.
text.onKeyDown = function(e)
{
if (e.keyCode == 13)
{
frame.setStatusText("Enter is not allowed");
e.skip = false;
}
}
Removing an event handler, can be done by deleting the event property.
// Delete the event:
delete text.onKeyDown;


© 2002 - 2007 Franky Braem.