Aller au contenu principal
Version: 20 R7 BETA

FORM Event

FORM Event : Object

ParamètresTypeDescription
RésultatObjectObjet événement

Description

FORM Event returns an object containing information about the form event that has just occurred.FORM Event returns an object containing information about the form event that has just occurred.FORM Event returns an object containing information about the form event that has just occurred. Habituellement, vous utiliserez FORM Event à partir d'une méthode formulaire ou objet.

Objet retourné

Each returned object includes the following main properties:

PropriétéTypeDescription
objectNametextNom de l'objet générant l'événement - Non inclus si l'événement est déclenché par le formulaire
codeintegerValeur numérique de l'événement formulaire.
DescriptiontextName of the form event (e.g. "On After Edit"). See the Form Events section.

For example, in the case of a click on a button, the object contains the following properties:

{"code":4,"description":"On Clicked","objectName":"Button2"}

The event object can contain additional properties, depending on the object for which the event occurs. For eventObj objects generated on:

  • List box or list box column objects, see the list box documentation on developer.4d.com.
  • 4D View Pro areas, see On VP Ready form event.

Note: If there is no current event, FORM Event returns a null object.

Exemple 1

You want to handle the On Clicked event on a button:

 If(FORM Event.code=On Clicked)
    ...
 End if

Exemple 2

If you set the column object name with a real attribute name of a dataclass like this:

You can sort the column using the On Header Click event:

 Form.event:=FORM Event
 Case of
    :(Form event code=On Header Click)
       if(Form.event.columnName="lastname")
          Form.employees:=Form.employees.orderBy(Form.event.columnName+", firstname")
       End if
 End case

Exemple 3

You want to handle the On Display Details on a list box object with a method set in the Meta info expression property:

The setColor method:

 var $event;$0;$meta : Object
 $event:=FORM Event
 $meta:=New object
 
 Case of
    :($event.code=On Display Detail)
       If($event.isRowSelected)
          $meta.fill:="lightblue"
       End if
 End case
 $0:=$meta

The resulting list box when rows are selected:

Voir également

Form Events Form event code