4D v14Video script |
||
|
4D v14
Video script
Video script
In this video, we're going to learn how events work and how to program them. First of all, let's distinguish between:
Form events are only triggered when a form is used (on screen or when printing), therefore when the interface is being used by a user (clicks, drag-and-drop, selection of menu items, keystrokes and so on). Database events only concern 3 actions that are performed on the data:
These 3 events are intercepted by the database engine. This is important to note because in Client/Server mode, the database engine runs on the server so you will never see a database event performed on your client machine. You won't be able to trace one from a client machine either. We'll come back to database events later on. First of all, we're going to have some fun and create a button that's a little "special".
and enter the following code: //Location of the mouse when the method starts this all means that:
Let's see what this gives us:
Each time you get near the button, it moves in the opposite direction (left, right, up or down). If the button falls off the screen, close the form and start again; the button will re-appear in its initial location. So that was one example of using events. Let's look at another one: when entering an intervention, we want to calculate its duration based on the information entered in the start time and end time. We will need to:
The duration is recalculated as being the difference between the end time less the intervention time, on the condition that the end time is filled in (in other words, not zero). We can copy the code and now create the end time method. When we're going to modify it: the intervention time must be filled in and the calculation of the duration will always be the same.
The programming was actually executed when we exited the field; in other words, in the context of the "On Data Change" event. In the next section, we're going to cover programming arrays. |
PROPERTIES
Product: 4D ARTICLE USAGE
Self-training ( 4D v13) |