OnItemValidate picture event


Declaration
Global handler:
 ENTRY   OnItemValidate(IN INT _refId, INT _row, INT _col, IN TEXT _value, BOOL _bValid)
 ; script actions
 END  OnItemValidate

Special handler:
 ENTRY XXX_OnItemValidate(INT _row, INT _col, IN TEXT _value, BOOL _bValid) 
 ; script actions
 END XXX_OnItemValidate

Parameters
_refId Parameter of INT type (required for global handler).
XXX Name of Reference variable connected to graphic object (without the character "_").
_row, _col Row, column of the item, whose value must be validated.
_value New item value.
_bValidate Output parameter - value validity attribute.

Description
The picture event is being generated by the displayer of Browser type, if the user want to finish the editing of item. Item is defined by row (_row) and column (_col). Owing to the backward compatibility, the parameter _col does not represent the index of column in a structure, but the order of column (from left), as it is displayed. Edited column must be of Text type.

If the picture event handler sets the output parameter to the value @False, the user cannot carry out the change. If the picture event handler sets the output parameter to the value @True, the change will be accepted.
When using the picture event, it allows easy performing the input check.


Example
In the example below, the picture handler for the displayer of Browser type with the reference variable _browser checks whether a value entered by user is lower or equal to the number of the item row. If the input is OK, then user can edit the item placed bellow the current one. If the item is placed in last row, next item to edit will be in first row.

The Browser displays the structured variable _rec.


 
ENTRY browser_OnItemValidate(INT _row, INT _col, IN  TEXT _value, BOOL _bValid)
   IF _col = 1 THEN
     INT _val
     _val := %StrToI(_value)
 
     IF !_val\VLD THEN
       _bValid := @FALSE
     ELSIF _val > _row THEN
       _bValid := @FALSE
     ELSE
       _bValid := @TRUE
       _row := _row+1
       IF _row > _rec\DIM THEN
         _row := 1
       ENDIF
     ENDIF
   ELSE
     _bValid := @TRUE
   ENDIF
 END browser_OnItemValidate
 
 BEGIN
    REDIM  _rec[10]
  END

 
Global picture event handler:
 
ENTRY OnItemValidate(IN  INT _refId, INT _row, INT _col, IN  TEXT _value, BOOL _bValid)
 IF _refId = _browser THEN    ;test that determines the displayer in which the event occurred
   ; script actions
  ENDIF
 END OnItemValidate

Note
Since the version 10.0.37 and higher, the next item for editing cannot be defined by the parameters _row and _col. This functionality is replaced by calling the function %HI_EditItem (for example from ENTRY OnItemChange).

0 komentárov

Nie ste prihlásený. Akékoľvek zmeny, ktoré vykonáte, sa označia ako anonymné. Ak už máte svoj účet, pravdepodobne sa budete chcieť prihlásiť .