I can’t seem to get the hang of the onHide event. What exactly triggers it, and when?
Per the documentation, I had thought (hoped) that I could use it to validate a record before allowing a user to, say, select another form. I created a method to validate, and if validation fails, return false. It seemed to run only some of the time, and even then it ran on the newly selected form, not the form I’d just hidden.
I tried a simpler method, with just a simple dialog, and it still seems a bit sporadic.
Am I just completely misunderstanding how this event works? It wouldn’t be the first time. Perhaps if someone could explain it in very small words?
The onHide is triggered when you hide the form. So what you should do is create a button that runs that method for you. And based on the result you do or don’t hide the form.
On top of the above you could use this part of the reference guide:
The method that is triggered when another form is being activated; NOTE: If the onHide method returns false, the form can be prevented from hiding. For example, when using onHide with showForm InDialog, the form will not close by clicking the dialog close box (X).
What actions by the user (or by a method) constitute “hiding” the form? Selecting another window? Clicking on a different form tab panel?
It’s the “hide” that has me confused. I understand Find, Sort, showAll, etc. I can’t find “hide” as a javascript command, nor as a labelled user button, so I’m not sure what really triggers this.
I can get a method to return false, but it seems to get to the ‘false’ step only AFTER it’s done what I would have considered “hiding” the form.
F’rinstance, I have a form with an onHide method that just shows a dialog and returns false. If I go under the Window menu and select another form, Servoy switches to that other form… and then shows me the dialog. I would have thought selecting another form would constitute “hiding” the current form.
I have a form called “Screen_companies”. The onHide event is g_actFrmHide, which just shows one line:
return false;
When I leave the form by the Window menu, back or forward, the method executes, but only AFTER I’ve gone to another form.
Per the documentation, quoted above by Marcel, returning false should prevent the form from hiding, but this doesn’t seem to be happening. By the time we return false, the deed is done.
I’m trying to understand this, as onHide seems perfectly suited for what I’m trying to do. Can anyone clear this up for me?
btw: What I want to do here is this: on some forms with complex validation rules, I want to start a transaction on ‘new’. That way, all the validation and field comparisons and such can be done at once, when the user leaves the record. At that point, we can show error messages, commit the record and/or rollback the transaction. I’m able to capture the user trying to leave the record by all other means except those that seem covered by the onHide.
Turns out, I did have debugger enabled, and onHide runs on the new form with debugger on.
Is this expected functionality? Is there a thread on this that I’ve missed?
I’m trying to get my events straight, and encountering some weirdness with others, as well. Could be my own error, of course, but are there other events that run in different sequence with debugger?
yes this is currently the case. You should always test in a disabled debugger as much as possible. Only when you really want to debug then start the debugger.
If you use the debugger then events are handled a bit different then in the client or developper with debugger disabled. I need to do this or you won’t be able to debug some events like focus gained or lost..
I still need to figure this out if i can make this better.