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
ItemEvent typedict
 
An ItemEvent indicates that an item in a component, like a JComboBox or Choice has undergone a state change because it was either selected or deselected. Components that display popup menus or menubars can also get ItemEvents from their menus. The fields in an ItemEvent are:
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.

item An Object that represents the item that was selected by the event. In practice, most itemStateChanged event handlers do their job without ever looking at item.
state An int that is 1 when the item was selected, and 0 otherwise.
Components like JButton, JComboBox, Checkbox, Choice, and List can receive ItemEvents, but they only arrive if the component has defined an itemStateChanged event handler. In addition, any component that displays a popup menu or menubar can get ItemEvents from those menus if they have an itemStateChanged event handler.
 
 Event Handlers:   itemStateChanged
 
 Example:   The program,
import yoix.*.*;

VM.exitmodel = 0;      // so main thread does not exit

JComboBox checkbox = {
    itemStateChanged(Event e) {
        printf("Received: %O\n", e);
        exit(0);
    }
};

ItemEvent event = {
    String id = "itemStateChanged";
    String item = "A fake event";
    int    state = 1;
};

printf("Posting: %O\n", event);
postEvent(event, checkbox);
prints
Posting: Event[3:0]
    id=^"itemStateChanged"
    item=^"A fake event"
   >state=1
Received: Event[3:0]
    id=701
    item=^"A fake event"
   >state=1
on standard output. Notice how the id field changed from a string to the corresponding integer by the time itemStateChanged got the event.
 
 See Also:   ActionEvent, AdjustmentEvent, CaretEvent, ChangeEvent, ComponentEvent, DragGestureEvent, DragSourceEvent, DropTargetEvent, Event, FocusEvent, HyperlinkEvent, InvocationEvent, invokeLater, isDispatchThread, KeyEvent, ListSelectionEvent, MouseEvent, MouseWheelEvent, PaintEvent, postEvent, TextEvent, TreeSelectionEvent, WindowEvent

 

Yoix is a registered trademark of AT&T Inc.