AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
InvocationEvent typedict
 
An InvocationEvent is a special, general-purpose event. Yoix programs can build them and use postEvent to send them to the invocationRun event handler defined in any AWT or Swing component. An InvocationEvent can grow, which means you can add fields whenever you want, but your names must not collide with following fields:
etc A field that is not currently used and may not be defined, but it should be considered reserved for releases.
id An Object that must be an int or String, that identifies the type of this event. A value that is a String must be the name of an event handler that can process this event. A value that is an int must be a number that the yoix.event.HandlerID dictionary associates with an event handler that can process this event.

In practice, id is only used when you build an event that gets handed to postEvent, and in that case the value assigned to id is almost always a String.

Most components can receive InvocationEvents, but they only arrive if the component has defined an invocationRun event handler.

InvocationEvents are also used by the JTable event handlers invocationAction, invocationChange, invocationEdit and invocationSelection and the JTree event handler invocationBrowse.
 
 Event Handlers:   invocationAction, invocationChange, invocationBrowse, invocationEdit, invocationRun, invocationSelection
 
 Example:   The program,
import yoix.*.*;

Button b = {
    invocationRun(Event e) {
        if (e.counter++ < 3)
            printf("invocationRun: e=%O\n", e);
        else exit(0);
    }
};

InvocationEvent ie = {
    String id = "invocationRun";
    int    counter = 0;           // custom field
};

while (TRUE) {
    postEvent(ie, b);
    ie.counter++;
    sleep(1.0);
}
prints
invocationRun: e=Event[2:0]
    counter=1
   >id=^"invocationRun"
invocationRun: e=Event[2:0]
    counter=2
   >id=^"invocationRun"
invocationRun: e=Event[2:0]
    counter=3
   >id=^"invocationRun"
on standard output. Notice that we added a custom field named counter to the InvocationEvent that we sent to the button, and that the button's invocationRun event handler checked and incremented counter each time it was called. The important point to remember here is that postEvent always sends a copy of the event, rather than the event itself. That means the button will not notice that counter changed right after postEvent returned and we will not notice that the button's invocationRun changed counter in the event that it received.
 
 See Also:   ActionEvent, AdjustmentEvent, CaretEvent, ChangeEvent, ComponentEvent, DragGestureEvent, DragSourceEvent, DropTargetEvent, Event, FocusEvent, HyperlinkEvent, invokeLater, isDispatchThread, ItemEvent, KeyEvent, ListSelectionEvent, MouseEvent, MouseWheelEvent, PaintEvent, postEvent, TextEvent, TreeSelectionEvent, WindowEvent

 

Yoix is a registered trademark of AT&T Inc.