ON ACTION Clause

 

 

Element

Description

Field List

A list of one or more form fields separated by commas

Action List

A list that consists of one to four actions separated by commas and enclosed in quotation marks

 

The actions which you have assigned to the buttons in the form specification file can be used in an ON ACTION clause. The ON ACTION clauses are treated by 4GL very much like the ON KEY clauses. 4GL executes the statements specified in it, when the user presses a button or other widget on the form to which the corresponding action is assigned. Whereas an ON KEY clause does not necessarily refer to a form widget and can be activated with the help of the keyboard, an ON ACTION clause is activated with the help of a form widget.

 

An event (action) can be assigned to the following widgets: button, radio button, check box, function field, and hotlink. It must be entered into the corresponding field in the Graphical Form Editor without quotation marks and white spaces. In the text form editor it must be enclosed into quotation marks:

 

CONFIG = "action {Name of the Button}"

 

The actions in an ON ACTION clause must be represented by a character string enclosed both in quotation marks and in parentheses and it must be the same as the name of the action in the form specification file:

 

ON ACTION ("action")

 

Lycia 3 also supports an in-built action named "doubleclick". The statements specified in the ON ACTION ("doubleclick") control block are invoked when the user performs a double click of the left mouse button at any place of the application window.

 

ON ACTION ("doubleclick")

 

It is also possible to set different doubleclick actions for different form widgets. To do this, one should add the INFIELD clause and specify the field or fields, double clicking on which should invoke the statements in the ON ACTION block:

 

ON ACTION ("doubleclick")INFIELD (f001)

 

There can be any number of the ON ACTION clauses in an INPUT statement. Up to four actions enclosed in quotation marks and separated by comas may be included into one ON ACTION clause.

 

As well as with the ON KEY clause, any 4GL or SQL statements can be included into an ON ACTION clause. The statements of a corresponding ON ACTION clause are executed when the widget within a screen form to which the action is assigned is pressed. The form where the INPUT statement takes place is deactivated while the statements are executed, though the statement is not terminated and the form will be reactivated, when 4GL finishes executing the ON ACTION clause, unless it contains the EXIT INPUT statement. If the ON ACTION clause contains the EXIT INPUT statement, the INPUT statement will be terminated.

 

The example below represents an ON ACTION clause which is triggered when the button with the "default" event is pressed:

 

ON ACTION ("default")

CALL display_default_values()

 

Infield Option

 

The ON ACTION clause of the INPUT and INPUT ARRAY statements can include an optional infield() operator. This operator specifies a field or a list of fields for which the ON ACTION clause will be triggered. If the action referenced by the ON ACTION clause is triggered, and the cursor is located in one of the fields specified in the infield() operator, the statements contained in such ON ACTION clause will be executed. However, if the cursor is not located in any of the fields specified in the field list of the infield() operator, the ON ACTION clause will be ignored, even if the corresponding action is triggered.

 

If the infield() operator is omitted, the ON ACTION clause will be executed when the referenced action is triggered regardless of the cursor position. If one and the same INPUT statement has two ON ACTION clauses referencing the same action, but one of them has the optional infield() operator, the ON ACTION... INFIELD() will be executed when the cursor is in one of the referenced fields and the specified action is triggered, in all other cases the ON ACTION clause without the infield() operator will be executed.

 

In the example below the ON ACTION event will be triggered, if the cursor is positioned in field f4 and the action is triggered. If the cursor is located in any field except f4, the ON ACTION clause will be ignored and nothing will happen.

 

INPUT BY NAME f1,f2,f3,f4

ON ACTION("test_action") INFIELD(f4)

CALL fgl_message_box("ON KEY event for field f4")

END INPUT