Form close method in servoy

I need to be able to write some code for the red x that closes or cancel a form in a dialogbox. I have a cancel button coded, but I would like for the red x to function the same as my cancel button. Right know my cancel button works great and rolls back edited records. However, the red x that exits the form appears to have no properties that I can assign code to for adjustment.

You can use the onHide event.

I been trying to get the onhide event to work. I am using a global variable in my data validation that will return 0 or 1 if the data is good. Then I just return the value in the on hide method. However, it seems to not be working properly.

return globals.data_is_valid;

However, it seems to not be working properly

So you are doing something wrong.

Is your global of a number type?

Do you have more success when you return true or false?

ok, got the onhide method to function like my cancel button. I just put my cancel method code in the onhide method.