The jsEvent object is the main communication channel for BlueJscript. Events generated by BlueJ are send to this queue of events, also events generated by the user typing something in the jsConsole are send here. If an extension writer needs to wait for some external events it normally wait using this object. A typical waiting loop may be.
function waitInvocation ( ) { anEvent = null; jsConsole.statusSet ('Waiting for an Event'); while ( (anEvent = jsEvent.get()) != null ) { // We wait for Invocation Events if ( anEvent.getClass() == "class bluej.extensions.event.InvocationEvent" ) break; } jsConsole.statusSet ('Event Received'); return anEvent; }
The above loop will exit when the received event Class is of type bluej.extensions.event.InvocationEvent or jsEvent.get() returns null. JsEvent.get() can return null if there is an interrupt received in the waiting loop.
Once an event of the desired value has been received then it can be precessed accordingly with the desired type.