Events and macro execution

When a macro is attached to an event (e.g. losing focus), it is unclear to me whether it runs before or after the event has been processed, and whether one can influence this. Referring to a previous database application (Paradox), one could use a command ‘DoDefault’ at either the beginning or the end of the macro to control the order of execution (including ‘DisableDefault’ if one wanted to cancel an event). Does LO have any equivalent mechanism?

I have noticed from other posts that certain events/macros in LO Base run twice. Again, in Paradox, this was explicit as an event was received by the form, acted upon or sent to the target, and then acted on again as it bubbled up afterwards. This could be managed by the statement

if eventInfo.isPrefilter then [actions to be handled by target]
else [actions to be handled by form]
endif

I suppose that one might find out what is happening with LO by setting a counter (as a global variable outside the macro) which is incremented each time it is run and could perform actions conditional on whether the counter has an even or odd number - ?

Hello,

In most cases it should be clear when the macro is called. The name of the event often notes this such as - Before/After record change

There is much about events throughout previously mentioned documentation. There is also a section on Handlers (event processing) in the OOME document by Pitonyak.

Here are a couple of more links on some descriptions of events:

Events 1

Events 2

(Note: edit to add missing link)

Also on this post, see my updated sample under Edit #2 which on Sheet2 of that sample is a matrix of controls and the events.

There is no simple answer to your question as there is so much to cover. It is easier to research existing documents/questions (have posted many answers on handlers/events) or ask a specific question.

Edit 2020-06-01:

Here are a few items which may help. While the Approve action is not available for all incidents, it is useful for things such as verifying data entered and then rejecting the update if there is a problem.

Many events can be cancelled by simply exiting the sub.

By creating a handler for key pressed/released you can reject certain key strokes. See How to properly code a broadcaster and listener in LO Basic and Ctrl+Enter in Calc

There is no “cancel” event in LO.

Depending upon the event, there are reasons for some events to occur multiple times.

Thank you. Much to learn in this area.