Search code examples
libreoffice

LibreOffice Button Approve or Execute


Could someone explain me, put an example or something about the difference between the triggers "Approve Action" and "Execute Action" of the LibreOffice buttons? Both trigger the same way when pressing the button. I read this on the libreoffice wiki but I cant really figure out.

Approve action

This event takes place before an action is triggered by clicking the control. For example, clicking a "Submit" button initiates a send action; however, the actual "send" process is started only when the When initiating event occurs. The Approve action event allows you to kill the process. If the linked method sends back FALSE, When initiating will not be executed.

Execute action

The Execute action event occurs when an action is started. For example, if you have a "Submit" button in your form, the send process represents the action to be initiated.


Solution

  • Presumably, as the text says, the Approve action could be used to conditionally cancel the event. If you never need to do that, then the Execute action will run your code when the button gets pressed, after the action is approved.

    Most likely this will work as expected for buttons. However, I have worked with certain controls and events where returning False from an event handler fails to cancel the event. My suspicion for those cases is that canceling still can happen deeper in the LibreOffice code but is not exposed through the API.