FOCUS system handle

A handle to the field-level widget that is the current field.

Note: Does not apply to SpeedScript programming.

Syntax

FOCUS [ :attribute ]
attribute
An attribute of the widget that has current input focus.

Attributes

The specific attributes available depend on the type of the widget. You can determine the widget type by examining the FOCUS:TYPE attribute.

Example

The following example uses the FOCUS handle to provide helpful information to the user. The procedure displays an interface that contains several different types of widgets. If you type ?, the procedure displays a message specifying the type of widget that has focus and whether VALUE-CHANGED event is a valid event for that widget.

r-focus.p

DEFINE VARIABLE inv-price   LIKE item.price NO-UNDO.
DEFINE VARIABLE inv-value   LIKE item.price NO-UNDO.
DEFINE VARIABLE report-type AS INTEGER      NO-UNDO INITIAL 1.

DEFINE BUTTON ok-butt     LABEL "OK" AUTO-GO.
DEFINE BUTTON cancel-butt LABEL "CANCEL" AUTO-ENDKEY.
      
FORM
  inv-price LABEL "Price" AT ROW 1.25 COLUMN 2
  report-type LABEL "Report Sorted ..." AT ROW 2.25 COLUMN 2 
    VIEW-AS RADIO-SET 
      RADIO-BUTTONS "By Catalog Page", 1, "By Inventory Value", 2 SKIP
  ok-butt cancel-butt
  WITH FRAME select-frame SIDE-LABELS.

ON ? ANYWHERE DO:
  MESSAGE "This is a" FOCUS:TYPE + ". VALUE-CHANGED is"
    (IF VALID-EVENT(FOCUS, "VALUE-CHANGED") THEN "a" ELSE "NOT a")
    "valid event for this widget."
    VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
  RETURN NO-APPLY.  
END.

ENABLE ALL WITH FRAME select-frame.
WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW.

Note that this example prevents you from entering the question mark character (?) in any field. This does not cause a problem in r-focus.p because a question mark is not a valid input character for any field in the interface.

Notes

See also

SELF system handle, WAIT-FOR statement (ABL only)