Event block
The event block of the FORM statement - a set of constructions controlling events in an interactive form view.
Syntax
[EVENTS] formEventDecl1, ..., formEventDeclN
Where each formEventDecli has the following syntax:
ON eventType [replaceMode] eventAction
Where eventType is one of the following forms:
INIT
OK [eventPhase]
APPLY [eventPhase]
CANCEL
CLOSE
DROP
CHANGE objName
[CHANGE] OBJECT objName
[CHANGE] groupObjectEvent groupObjectName
[CHANGE] FILTERGROUPS filterGroupName
[CHANGE] FILTERS PROPERTY formPropertyName
[CHANGE] PROPERTY [eventPhase] formPropertyName
QUERYOK
QUERYCLOSE
containerEvent componentSelector
SCHEDULE PERIOD intPeriod [FIXED]
Where eventAction is one of the following forms:
eventActionId(param1, ..., paramK)
{ eventActionOperator }
Description
The event block allows to define handlers for form events that occur as the result of certain user actions. Each block can have an arbitrary number of comma-separated event handlers. If several handlers are defined for an event, they are guaranteed to be executed in the order they are defined.
Parameters
-
objNameName of an object on the form. Simple ID.
-
groupObjectNameName of an object group on the form. Simple ID.
-
filterGroupNameName of a filter group on the form. Simple ID.
-
formPropertyName -
componentSelectorDesign component selector.
-
groupObjectEventOne of
FILTER,ORDER,FILTERS,ORDERS. -
containerEventOne of
EXPAND,COLLAPSE,TAB. -
eventPhaseOne of
BEFORE,AFTER. When omitted fromOK/APPLY, the handler runs on the event itself; when omitted fromPROPERTY, it sets the singleCHANGEhandler for the property (seereplaceMode). -
intPeriodThe scheduler period in seconds (an integer literal).
-
FIXEDKeyword. When specified, the period to the next run is counted from the start of the current action instead of from its end.
-
replaceModeControls whether the handler replaces previously defined handlers for this event or is added to them.
REPLACEreplaces all handlers previously defined for the event;NOREPLACEadds the handler to them. When omitted, the default isREPLACEforQUERYOKandQUERYCLOSEandNOREPLACEfor all other events.replaceModedoes not apply to the plainPROPERTYevent form (withoutBEFORE/AFTER), which always replaces its single handler. -
eventActionIdThe ID of the action, that will be the event handler.
-
param1, ..., paramKList of action parameters. Each parameter is specified with the object name on the form. The object name, in turn, is specified with a simple ID.
-
eventActionOperatorContext-dependent action operator. You can use the names of already declared objects on the form as parameters.
Examples
showImpossibleMessage() { MESSAGE 'It\'s impossible'; };
posted = DATA BOOLEAN (Invoice);
FORM invoice 'Invoice' // creating a form for editing an invoice
OBJECTS i = Invoice PANEL // creating an object of the invoice class
// ... setting the rest of the form behavior
EVENTS
// specifying that when the user clicks OK, an action should be executed
// that will execute actions to "conduction" this invoice
ON OK { posted(i) <- TRUE; },
// by clicking the formDrop button, showing a message that this cannot be,
// since this button by default will be shown only in the form for choosing an invoice,
// and this form is basically an invoice edit form
ON DROP showImpossibleMessage()
;
CLASS Shift;
currentShift = DATA Shift();
CLASS Cashier;
currentCashier = DATA Cashier();
CLASS Receipt;
shift = DATA Shift (Receipt);
cashier = DATA Cashier (Receipt);
FORM POS 'POS' // declaring the form for product sale to the customer in the salesroom
OBJECTS r = Receipt PANEL // adding an object that will store the current receipt
// ... declaring the behavior of the form
;
createReceipt () {
NEW r = Receipt {
shift(r) <- currentShift();
cashier(r) <- currentCashier();
ACTIVATE POS.r = r;
}
}
// extending the form with an ON INIT handler so that opening it runs createReceipt,
// which creates a new receipt and makes it the current object on the form
EXTEND FORM POS
EVENTS
// when opening the form, executing the action to create a new receipt,
// which fills in the shift, cashier and other information
ON INIT createReceipt()
//apply every 60 seconds
ON SCHEDULE PERIOD 60 FIXED apply();
;