# onHide

**URL:** <https://forum.servoy.com/t/onhide/3105>\
**Category:** Classic Servoy\
**Created:** [November 20, 2004, 9:20pm UTC](https://forum.servoy.com/t/onhide/3105 "2004-11-20T21:20:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cain](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@Cain](https://forum.servoy.com/u/Cain)\
**Post date:** [November 20, 2004, 9:20pm UTC](https://forum.servoy.com/t/onhide/3105/1 "2004-11-20T21:20:59Z")

</div>

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. ![:wink:]( "Wink") Perhaps if someone could explain it in very small words? ![:lol:]( "Laughing")

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [November 20, 2004, 9:38pm UTC](https://forum.servoy.com/t/onhide/3105/2 "2004-11-20T21:38:50Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Cain](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@Cain](https://forum.servoy.com/u/Cain)\
**Post date:** [November 20, 2004, 10:00pm UTC](https://forum.servoy.com/t/onhide/3105/3 "2004-11-20T22:00:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Cain](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@Cain](https://forum.servoy.com/u/Cain)\
**Post date:** [November 21, 2004, 7:11pm UTC](https://forum.servoy.com/t/onhide/3105/4 "2004-11-21T19:11:07Z")

</div>

I have a form called “Screen\_companies”. The onHide event is g\_actFrmHide, which just shows one line:

```auto
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. ![:wink:]( "Wink")

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.

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [November 22, 2004, 12:41pm UTC](https://forum.servoy.com/t/onhide/3105/5 "2004-11-22T12:41:29Z")

</div>

do you have the debugger enabled?  
What happens if you disable the debugger is then the onHide also called after the new form is shown?

If you have onHide on formA and onShow on formB and you go from formA to formB then onHide is called first? Then the sequence is ok.

---

<div class="post-metadata">

**Author:** ![Cain](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@Cain](https://forum.servoy.com/u/Cain)\
**Post date:** [November 22, 2004, 4:01pm UTC](https://forum.servoy.com/t/onhide/3105/6 "2004-11-22T16:01:37Z")

</div>

It’s working this morning. Not sure if it’s the machine or the operator that needed refreshing. ![:oops:]( "Embarassed")

---

<div class="post-metadata">

**Author:** ![Cain](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@Cain](https://forum.servoy.com/u/Cain)\
**Post date:** [November 22, 2004, 6:53pm UTC](https://forum.servoy.com/t/onhide/3105/7 "2004-11-22T18:53:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [November 22, 2004, 7:30pm UTC](https://forum.servoy.com/t/onhide/3105/8 "2004-11-22T19:30:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Cain](https://avatars.discourse-cdn.com/v4/letter/c/85e7bf/32.png) [@Cain](https://forum.servoy.com/u/Cain)\
**Post date:** [November 22, 2004, 7:43pm UTC](https://forum.servoy.com/t/onhide/3105/9 "2004-11-22T19:43:10Z")

</div>

OK. At least I know I’m not nuts…

Well, at least not for this reason… ![;-)]( "Wink")
