LibreOffice Button Approve or Execute - libreoffice

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.

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.

Related

How to make a button trigger an event (Timer)?

I am working on a fire evacuation project and would like to trigger an event after clicking a button. Basically I want to begin the fire evacuation process manually using the button feature but would like to trigger a timer for about 60 seconds to give the pedestrians time to evacuate using the event feature.
I have tried to make pedestrians stop the evacuation process by manually clicking another button but would like to use an event trigger timer instead as this will be a better way to conduct my simulation. I cannot seem to trigger an event once the button is clicked. I've tried changing the trigger type but not sure where to go from there. Is there any code that is required or another step that is required?
Even though a dynamic event is fine in your application, you can also use a user control event:
And then in your button you can use the following code:
event.restart(60,SECOND); //you can choose any timeout here
or
event.restart(); // this will use the configuration, which in this case I set up to 60 seconds
The difference between a dynamic event and a user controlled event is that if you click the button again:
With the dynamic event, you will generate another instance of the event, meaning that if you click the button at t=0 seconds, and t=30 seconds, you will generate 2 events at t=60 seconds and t=90 seconds
With the user control event, you will restart the same event. if you click the button at t=0 seconds, and t=30 seconds, you will generate a unique event at t=90 seconds.
So depending on which one you prefer... you can choose. I would prefer the user control in case you click the button 2 times... or if you regret clicking it so fast... I don't know
Use the Dynamic Event for this.
Set it up by pulling it from the AnyLogic Agent Library to the Workspace and give it a name (here: MyDynamicEvent).
Add the code you want to have executed when the timer runs off in the Action field
Set one (or several) timed instance for this event by using the code create_MyDynamicEvent(60,SECOND);. Note: The syntax of this statement is always create_ followed by the actual name you gave your DynamicEvent type.

Prevent users from typing and clicking in MS Word Add-in

I am writting a MS Word Add-in, I create a button to run a long time work with text. My work requires that during the time it is excuted, no change can be made by user ( typing, clicking, deleting ...) When this work is completed, user can type and click as usual.
I have used
this.Application.Options.AllowClickAndTypeMouse = false;
However, this doesn't work.
Who can help me!
First, your approach is wrong. The Click and Type is Word functionality and has nothing to do with disabling user Mouse clicks
(For more information about Click and Type refer to here).
Now for your question, here is one approach I would suggest:
If the user is not able to do any action, I would expect an appropriate message, so my idea is to create a modal form by using:
myForm.ShowDialog();
It should do the job and block the active document until it get closed.
I would also add a nice progress bar and "Close" button which you will enable when work has done.

LostFocus method of a text box getting executed before Form_Unload

I am currently programming in MS Access VBA. I have a form with a textbox on it. I am executing some code on LostFocus event of the textbox.
However, when I close the form using mouse and by clicking on close button on right-top corner of the form, with cursor in the text box, I have noticed that LostFocus event is getting executed before Form_Unload event.
Is there a way to avoid this?
Also, where can I find priorities of the events?? Or How are priorities decided in VBA?
EDIT:
My exact application is like this.
I have a form in MS Access which is used for accepting users' login credentials.
I want to disble textbox for Password and Login button till a valid Username is entered. I check if the username is valid or not on onLostFocus event. Now, consider a case where this form is closed without entering anything in Username textbox. In that case, onLostFocus event gets executed before Form_Unload event.
However, for normal operation, I require onLostFocus event because, on that event I enable Password textbox and login button.
Could there be a different way of doing it??
The lost focus event is not usually the best event for code. Did you have a specific reason for using it? If so, you will need to add a condition to the execution.
The order of events for an Access form are:
Exit → LostFocus
If you are closing a form, the Exit and LostFocus events occur before
the events associated with closing the form (such as Unload,
Deactivate, and Close), as follows:
Exit (control) → LostFocus (control) → Unload (form) → Deactivate
(form) → Close (form)
-- http://office.microsoft.com/en-ie/access-help/order-of-events-for-database-objects-HP005186761.aspx
"I check if the username is valid or not on onLostFocus event."
Do your validation in the after update event of the username text box ... enable/disable the password text box as appropriate when the username value changes.
You can initially disable the the password text box at form load, assuming the form loads with the username text box empty.
using onDirty or onChange is probably better for what you're doing if it is a control that you're inserting data into. There's a bunch of better choices than onLostFocus. Without knowing anything specific makes it tough to know how to help you more specifically. I'd say just try another on Event, because due to the nature of onLostFocus, it'd be impossible to prepare for this contingency.

lift disabling back button actions

I'm creating a transaction related site using lift. In here, there's a requirement to show a success page after the user action.
when i make action happen and press the browser's back button. it again goes to the previous page(before transaction page) making the transaction doable again. I need to limit this behavior. Is there any way of limiting the access to previous page by browser back button in lift.
There is no way to reliably stop the user from returning to the URL, but you can stop them from invoking the action more than once. Take a look at S.oneShot. From the Scala Doc:
All functions created inside the oneShot scope will only be called
once and their results will be cached and served again if the same
function is invoked
If you wrap the function that occurs when the button is pressed, even if the user does return to the page and click the button a second time, the body of the function shouldn't be invoked again.

GXT KeyListener.componentKeyDown() immediately closes MessageBox.alert()

In GXT, MessageBox methods are asynchronous, meaning that the application does not "lock up" while the message box is displayed.
I using a KeyListener to process enter key presses in a form (to increase usability, i.e., allowing the form to be submitted by the enter key) and subsequently disabling the form fields while the application processes the user's credentials. If they are incorrect, I show a MessageBox.alert() and then re-enable the form fields. However, since alert() returns immediately, the form fields are immediately made available again, allowing the user to input data without closing the alert.
The solution is to use a callback in alert(); however, the enter keypress not only causes the form to submit, but also causes the alert to immediately dismiss (as if both the form and the message box are processing the enter key). How do I keep the alert box open until the user presses enter a second time or clicks the "Ok" button?
The key is DeferredCommand provided by GWT:
This class allows you to execute code after all currently pending event handlers have completed, using the addCommand(Command) or addCommand(IncrementalCommand) methods. This is useful when you need to execute code outside of the context of the current stack.
if(!validate())
{
DeferredCommand.addCommand(new Command() {
public void execute() {
MessageBox.alert("Error", "You must enter a username and password.", alertListener);
return;
}
});
}