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

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YDAT | YWAIT | Byzgraf | FAQs
FocusEvent typedict
 
A FocusEvent indicates that a component has gained or lost the keyboard focus. The fields in a FocusEvent 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.

temporary An int that is 1 when the focus change is temporary and 0 otherwise.
Most components can receive FocusEvents, but they only arrive if the component has defined one or more of the event handlers listed below.
 
 Event Handlers:   focusGained, focusLost
 
 Example:   The program,
import yoix.*.*;

JFrame f = {
    FlowLayout layoutmanager = {
        int vgap = 72;
        int hgap = 72/8;
    };

    Array layout = {
        new JTextField {
            String tag = "$_textfield";
            String text = "This is a test";
            int    columns = 20;

            focusGained(Event e) {
                printf("JTextField.focusGained: %O\n", e);
            }

            focusLost(Event e) {
                printf("JTextField.focusLost: %O\n", e);
            }
        },

        new JButton {
            String text = "Clear";
            int    requestfocus = TRUE;

            focusGained(Event e) {
                printf("JButton.focusGained: %O\n", e);
            }

            focusLost(Event e) {
                printf("JButton.focusLost: %O\n", e);
            }

            actionPerformed(e) {
                root.components.$_textfield.text = NULL;
            }
        },
    };
};

f.visible = TRUE;
adds focusGained and focusLost event handlers to a JTextField and JButton, puts them both in a frame, and uses the button's requestfocus field ask for the focus when the frame first becomes visible.
 
 See Also:   ActionEvent, AdjustmentEvent, CaretEvent, ChangeEvent, ComponentEvent, DragGestureEvent, DragSourceEvent, DropTargetEvent, Event, HyperlinkEvent, InvocationEvent, invokeLater, isDispatchThread, ItemEvent, KeyEvent, ListSelectionEvent, MouseEvent, MouseWheelEvent, PaintEvent, postEvent, TextEvent, TreeSelectionEvent, WindowEvent

 

Yoix is a registered trademark of AT&T Intellectual Property.