Saltar para o conteúdo principal
Versão: v19

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.

Objecto evento

Each event is returned as an object by the FORM Event command. Por defeito, contém as seguintes propriedades:

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

Form event code command| |description|text|Name of the form event (e.g. "On After Edit")|

Propriedades adicionais são retornadas quando o evento ocorre em objetos específicos. Em particular:

Eventos e métodos

Quando um evento formulário ocorre, 4D executa as seguintes ações:

  • 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 então continua a chamar os métodos objeto do formulário pai. 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

A tabela seguinte resume a forma como os métodos objeto e formulário são chamados para cada tipo de evento:

EventoMétodos objectoMétodo formulárioQue objectos
On LoadSimSimTodos os objectos
On UnloadSimSimTodos os objectos
On ValidateSimSimTodos os objectos
On ClickedSimSimApenas objecto envolvido
On Double ClickedSimSimApenas objecto envolvido
On Before KeystrokeSimSimApenas objecto envolvido
On After KeystrokeSimSimApenas objecto envolvido
On After EditSimSimApenas objecto envolvido
On Getting FocusSimSimApenas objecto envolvido
On Losing FocusSimSimApenas objecto envolvido
On ActivateNuncaSimNenhum
On DeactivateNuncaSimNenhum
On Outside CallNuncaSimNenhum
On Page ChangeNuncaSimNenhum
On Begin Drag OverSimSimApenas objecto envolvido
On DropSimSimApenas objecto envolvido
On Drag OverSimNuncaApenas objecto envolvido
On Mouse EnterSimSimTodos os objectos
On Mouse MoveSimSimTodos os objectos
On Mouse LeaveSimSimTodos os objectos
On Mouse UpSimNuncaApenas objecto envolvido
On Menu SelectedNuncaSimNenhum
On Bound variable changeNuncaSimNenhum
On Data ChangeSimSimApenas objecto envolvido
On Plug in AreaSimSimApenas objecto envolvido
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)SimNenhum, excepto List boxes
On Close DetailSim (List box)SimNenhum, excepto List boxes
On ResizeNuncaSimNenhum
On Selection ChangeSimSimApenas objecto envolvido
On Load RecordNuncaSimNenhum
On TimerNuncaSimNenhum
On ScrollSimNuncaApenas objecto envolvido
On Before Data EntrySim (List box)NuncaApenas objecto envolvido
On Column MovedSim (List box)NuncaApenas objecto envolvido
On Row MovedSim (List box)NuncaApenas objecto envolvido
On Column ResizeSim (List box e Area 4D View Pro)NuncaApenas objecto envolvido
On Header ClickSim (List box e Area 4D View Pro)NuncaApenas objecto envolvido
On Footer ClickSim (List box)NuncaApenas objecto envolvido
On After SortSim (List box)NuncaApenas objecto envolvido
On Long ClickSim (Botão)SimApenas objecto envolvido
On Alternative ClickSim (botão e List box)NuncaApenas objecto envolvido
On ExpandSim (Hier. lista e list box)NuncaApenas objecto envolvido
On CollapseSim (Hier. lista e list box)NuncaApenas objecto envolvido
On Delete ActionSim (Hier. lista e list box)NuncaApenas objecto envolvido
On URL Resource LoadingSim (Área Web)NuncaApenas objecto envolvido
On Begin URL LoadingSim (Área Web)NuncaApenas objecto envolvido
On URL Loading ErrorSim (Área Web)NuncaApenas objecto envolvido
On URL FilteringSim (Área Web)NuncaApenas objecto envolvido
On End URL LoadingSim (Área Web)NuncaApenas objecto envolvido
On Open External LinkSim (Área Web)NuncaApenas objecto envolvido
On Window Opening DeniedSim (Área Web)NuncaApenas objecto envolvido
On VP Range ChangedSim (Área 4D View Pro)NuncaApenas objecto envolvido
On VP ReadySim (Área 4D View Pro)NuncaApenas objecto envolvido
On Row ResizeSim (Área 4D View Pro)NuncaApenas objecto envolvido

Always keep in mind that, for any event, the method of a form or an object is called if the corresponding event property is selected for the form or objects. 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.