Skip to main content
Version: v19 R8 BETA

Visão Geral

Form events are events that can lead to the execution of the form method and/or form object method(s). Form events allow you to control the flow of your application and to write code that is executed only when a specific event occurs.

In your code, you control the events using the FORM Event command, that returns the triggered event. Por exemplo:

//code of a button If(FORM Event.code=On Clicked) 
// do something when the button is clicked End if

Every form and every active object on the form can listen to a predefined set of events, but only the events that you enabled at the form level and/or at every object level will actually occur.

Event object

Each event is returned as an object by the FORM Event command. By default, it contains the following properties:

PropriedadeTipoDescrição
objectNametextName of the object triggering the event - Not included if the event is triggered by the form

Additional properties are returned when the event occurs on specific objects. Em particular:

Eventos e métodos

When a form event occurs, 4D performs the following actions:

  • First, it browses the objects of the form and calls the object method for any object (involved in the event) whose corresponding object event property has been selected.
  • Second, it calls the form method if the corresponding form event property has been selected.

Do not assume that the object methods, if any, will be called in a particular order. The rule of thumb is that the object methods are always called before the form method. If an object is a subform, the object methods of the subform’s list form are called, then the form method of the list form is called. 4D then continues to call the object methods of the parent form. In other words, when an object is a subform, 4D uses the same rule of thumb for the object and form methods within the subform object.

Except for the On Load and On Unload events (see below), if the form event property is not selected for a given event, this does not prevent calls to object methods for the objects whose same event property is selected. In other words, enabling or disabling an event at the form level has no effect on the object event properties.

The number of objects involved in an event depends on the nature of the event.

Tabela de chamadas

The following table summarizes how object and form methods are called for each event type:

EventoMétodos objectoMétodo formulárioObjectos
On LoadSimSimTodos os objectos
On UnloadSimSimTodos os objectos
On ValidateSimSimTodos os objectos
On ClickedSimSimInvolved object only
On Double ClickedSimSimInvolved object only
On Before KeystrokeSimSimInvolved object only
On After KeystrokeSimSimInvolved object only
On After EditSimSimInvolved object only
On Getting FocusSimSimInvolved object only
On Losing FocusSimSimInvolved object only
On ActivateNuncaSimNenhum
On DeactivateNuncaSimNenhum
On Outside CallNuncaSimNenhum
On Page ChangeNuncaSimNenhum
On Begin Drag OverSimSimInvolved object only
On DropSimSimInvolved object only
On Drag OverSimNuncaInvolved object only
On Mouse EnterSimSimTodos os objectos
On Mouse MoveSimSimTodos os objectos
On Mouse LeaveSimSimTodos os objectos
On Mouse UpSimNuncaInvolved object only
On Menu SelectedNuncaSimNenhum
On Bound variable changeNuncaSimNenhum
On Data ChangeSimSimInvolved object only
On Plug in AreaSimSimInvolved object only
On HeaderSimSimTodos os objectos
On Printing DetailSimSimTodos os objectos
On Printing BreakSimSimTodos os objectos
On Printing FooterSimSimTodos os objectos
On Close BoxNuncaSimNenhum
On Display DetailSimSimTodos os objectos
On Open DetailSim (List box)SimNenhuma exceto List boxes
On Close DetailSim (List box)SimNenhuma exceto List boxes
On ResizeNuncaSimNenhum
On Selection ChangeSimSimInvolved object only
On Load RecordNuncaSimNenhum
On TimerNuncaSimNenhum
On ScrollSimNuncaInvolved object only
On Before Data EntrySim (List box)NuncaInvolved object only
On Column MovedSim (List box)NuncaInvolved object only
On Row MovedSim (List box)NuncaInvolved object only
On Column ResizeSim (List box e área 4D View Pro)NuncaInvolved object only
On Header ClickSim (List box e área 4D View Pro)NuncaInvolved object only
On Footer ClickSim (List box)NuncaInvolved object only
On After SortSim (List box)NuncaInvolved object only
On Long ClickSim (Botão)SimInvolved object only
On Alternative ClickSim (Botão e List box)NuncaInvolved object only
On ExpandSim (Hier. lista e list box)NuncaInvolved object only
On CollapseSim (Hier. lista e list box)NuncaInvolved object only
On Delete ActionSim (Hier. lista e list box)NuncaInvolved object only
On URL Resource LoadingSim (Área Web)NuncaInvolved object only
On Begin URL LoadingSim (Área Web)NuncaInvolved object only
On URL Loading ErrorSim (Área Web)NuncaInvolved object only
On URL FilteringSim (Área Web)NuncaInvolved object only
On End URL LoadingSim (Área Web)NuncaInvolved object only
On Open External LinkSim (Área Web)NuncaInvolved object only
On Window Opening DeniedSim (Área Web)NuncaInvolved object only
On VP Range ChangedSim (Area 4D View Pro)NuncaInvolved object only
On VP ReadySim (Area 4D View Pro)NuncaInvolved object only
On Row ResizeSim (Area 4D View Pro)NuncaInvolved object only

Ter sempre em mente que, para qualquer evento, o método de um formulário ou de um objecto é chamado se a propriedade do evento correspondente for seleccionada para o formulário ou objectos. The benefit of disabling events in the Design environment (using the Property List of the Form editor) is that you can reduce the number of calls to methods and therefore significantly optimize the execution speed of your forms.

WARNING: The On Load and On Unload events are generated for objects if they are enabled for both the objects and the form to which the objects belong. If the events are enabled for objects only, they will not occur; these two events must also be enabled at the form level.