![]() |
Free EcmaScript Interpreter.
A JavaScript interpreter written in Java. |
Language extensions - Event processing |
The FESI event processing is capable to handle any Java 1.1 event, the event adaptor is built dynamically as needed.
If FESI is used as an embedded scripting capability in another product, the built-in event extension capability can be used or another set of capabilities can be developed, at the programmer choice.
Event procedures are of two kinds: functions (with the event as the parameter) or string to be evaluated. The parsing is done at the time of event establishement and parsing error are raised there. If a string if used, the variable event is bound to the first parameter of the handler method. The variable this is bound to the object for which the variable was registered. Only one event of a type can be registered on any object (that is on its wrapper). The event handler is unregistered by using null as event handler.
// Create the GUI
f = new Frame("An EcmaScript Frame");
f.setSize(200,200)
b = new Button("FESI");
f.add("Center",b)
f.pack();
f.show()
// Example of using twice the same action - the first one will be
// overridden and only the second action will be processed
b.onAction = "writeln ('ES Action 1');";
b.onAction = "writeln ('ES Action 2');";
// The event variable contains the event
b.onKeyTyped = "writeln('KEY: ' + event);";
// Use of a function - this is the object (wrapper) for which the
action was registered
function dispose(event) {
writeln();
writeln("Event received: " + event);
writeln("By: " + this);
this.dispose();
}
f.onWindowClosing = dispose;
writeln("ready");
}