Difference between revisions of "Event order"

From Free Pascal wiki
Jump to navigationJump to search
(→‎Lazarus documentation: OnCreate, OnDestroy)
m
Line 2: Line 2:
 
Lazarus offers various events that you can use to enter your own procedures to handle things that happen in your application (e.g. a user clicks a button).
 
Lazarus offers various events that you can use to enter your own procedures to handle things that happen in your application (e.g. a user clicks a button).
  
There are rather many possible events to cater for a lot of different scenarios. Somebody who does not know Lazarus or Delphi could well pick the wrong event.
+
There are rather a lot of possible events to cater for a lot of different scenarios. Somebody who does not know Lazarus or Delphi could well pick the wrong event.
  
 
== Lazarus documentation ==
 
== Lazarus documentation ==
Line 18: Line 18:
 
== Applicable Delphi information ==
 
== Applicable Delphi information ==
 
Because the implementation of events in Lazarus and Delphi is similar, a lot of Delphi-related documentation is applicable to Lazarus with minor modifications.
 
Because the implementation of events in Lazarus and Delphi is similar, a lot of Delphi-related documentation is applicable to Lazarus with minor modifications.
 
  
 
[http://docwiki.embarcadero.com/RADStudio/en/Events Delphi documentation] is often handy. You can search for the actual control you want to know more about to get a list of its events.
 
[http://docwiki.embarcadero.com/RADStudio/en/Events Delphi documentation] is often handy. You can search for the actual control you want to know more about to get a list of its events.
Line 25: Line 24:
  
 
[[Category:Lazarus]]
 
[[Category:Lazarus]]
 +
[[Category:LCL]]

Revision as of 07:29, 13 June 2013

Overview

Lazarus offers various events that you can use to enter your own procedures to handle things that happen in your application (e.g. a user clicks a button).

There are rather a lot of possible events to cater for a lot of different scenarios. Somebody who does not know Lazarus or Delphi could well pick the wrong event.

Lazarus documentation

The Lazarus_Tutorial#Event_Actions Lazarus tutorial has some information on what events do what.

Form.OnCreate

This is the equivalent to the class constructor in forms. Use this to initialize form-level variables etc.

Form.OnDestroy

The equivalent to a class destructor in forms. Use this to clean up/free variables.

OnEditingDone

The OnEditingDone event for controls can act like the Validate event in other programming languages: it indicates the user is done changing the control and intends to keep that value. The program can now check the control content for correctness, show error messages, update database fields, etc.

Applicable Delphi information

Because the implementation of events in Lazarus and Delphi is similar, a lot of Delphi-related documentation is applicable to Lazarus with minor modifications.

Delphi documentation is often handy. You can search for the actual control you want to know more about to get a list of its events.

If you want to know about the order in which events fire on a form, this article from about.com can be useful.