Previous Next

APPLY statement
Applies an event to a widget or procedure.
Syntax 
 
APPLY event [ TO widget-phrase ]
event
An expression whose value is the key code or event name that you want to apply. A special value of event is the value of the LASTKEY function. The LASTKEY function returns the keycode for the last event read from the user (that is, from the keyboard or mouse) or the last character read from an input file. The value event can be either a character-string value (event name) or an integer (key code) expression. For more information on default system actions and events, see the “Handle-based Object Events Reference” section.
TO widget-phrase
Specifies a widget or procedure to which the event is applied.
Example 
This procedure shows how to use the APPLY statement to create keyboard accelerators. When you run this procedure you can invoke the trigger block attached to the order-but button by choosing the button directly or by pressing F10 in the Name field. When you press F10, the AVM sends the CHOOSE event to the button. This is equivalent to choosing the button with the mouse.
 
DEFINE BUTTON order-but LABEL "Order"
  TRIGGERS:
    ON CHOOSE DO:
      FIND FIRST Order OF Customer NO-ERROR.
      IF AVAILABLE Order THEN
        UPDATE Order WITH FRAME upd-dlg
          VIEW-AS DIALOG-BOX TITLE "Update Order" SIDE-LABELS.
    END.
  END TRIGGERS.
 
FORM order-but Customer.Name WITH FRAME x.
   
ON F10 OF Customer.Name DO:
  APPLY "CHOOSE" TO order-but IN FRAME x.
END.
   
FIND FIRST Customer NO-LOCK.
DISPLAY order-but Customer.Name WITH FRAME x.
ENABLE ALL WITH FRAME x.
 
WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW.
Notes 
*
Regardless of whether there is a default system action associated with an event-widget pair, you can write a trigger for the pair. The APPLY statement executes a trigger associated with an event-widget pair. If the event-widget pair has a default system action, that action occurs before or after the trigger executes, depending on the event. For more information on default system actions and events, see the next note and the “Handle-based Object Events Reference” section.
*
One widget that does not have this difficulty is the fill-in. When you APPLY a character-string event to a fill-in, the character string appears in the image of the fill-in. The AVM accomplishes this by placing a copy of the character string into a buffer that maps to the same portion of the screen as the image of the fill-in.
*
*
*
*
If you are using APPLY in an EDITING phrase and expression is a key that causes a GO action (GO, or any key in a list used with the GO-ON option), the AVM does not immediately exit the EDITING phrase but instead processes all the remaining statements in the phrase. If RETRY, NEXT, UNDO RETRY, or UNDO NEXT is executed before the end of the phrase, the AVM ignores the GO and continues processing the EDITING phrase.
*
*
*
See also 
ON statement, Widget phrase

Previous Next
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates.