4D v14Events |
||
|
4D v14
Events
Events
In addition to the manipulations explained in the video, you should also note that: Not all objects have the same events: for example, you cannot check the "On Data Change" event for a button since you cannot "enter" its contents (title). Here are a few examples:
This list helps you understand events. You can refer to the 4D documentation for a complete description of events. There’s one important detail that new users always ask: “Do I need to check form events or object events?” The response is simple: everything depends on where you are going to create your method.
Whereas object methods should contain what is specific to an object itself (button, field, etc.). That's the general rule and you should have several good reasons before you consider breaking it. Keep this in mind:
It does happen that we move certain processes into the form method. For example, you must re-calculate a value depending on 10 enterable parameters. For each modified parameter, you must re-perform the calculation. Rather than put the formula (or method call) in each of the 10 parameter fields, it is possible to move this calculation into the form method. In this case, it’s easier and centralized; however, it is highly likely that the re-calculation will be done more often than necessary - especially when modifying an area that doesn’t figure in the final calculation. (Note: 4D can let you know which object was modified so we can adapt the calculation according to this information). It is important to know the order in which events are executed. For example, for a button, events are executed in the following order:
A field or a variable on which you click:
To save time when writing your code and to make it more reliable, remember to set up macros (“macros.xml” file). For example, you can create a macro that writes the following code for you whenever you type “#$evt” in your method: $evt:=Form event While you are still learning to use 4D, we recommend that you start off by putting your methods in your objects; you’ll have more flexibility for updating. Then, start by using generic method calls and finally, when everything works properly, see what you can move from your object methods to your form method or project methods. Then you can start passing pointers as well. To go further:
and of course, the old standbys:
|
PROPERTIES
Product: 4D ARTICLE USAGE
Self-training ( 4D v13) |