Saltar al contenido principal
Versión: Siguiente

FORM Event

FORM Event : Object

ParámetrosTipoDescripción
ResultadoObjectObjeto evento

Descripción

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.FORM Event returns an object containing information about the form event that has just occurred. Usually, you will use FORM Event from within a form or object method.

Objeto devuelto

Each returned object includes the following main properties:

PropertyTypeDescription
objectNametextNombre del objeto que desencadena el evento - No se incluye si el evento lo desencadena el formulario
codeintegerValor numérico del evento de formulario.
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.

Ejemplo 1

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

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

Ejemplo 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

Ejemplo 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:

Ver también

Form Events Form event code