I would like to know if there is an event that fires when a form is being closed in a module. If not, can one be created using JO? I am not from the Java world so the JO seems a bit strange, but hopefully this can be the beginning of my familiarisation.
I see that _CloseRequest event works in Main but does not seem to work in code modules with forms.
Ey I am pretty sure it works on code modules. There is no reason for not to.
Check.
That form is dimmed in the same module
that the event name is equal in the initialization and the sub.
Use the events shorcut (write the word Sub + tab) to get the correct event.
As @Enrique Gonzalez R stated just make sure your Initialization name = EventName.
B4X:
Public Sub StartModule 'this is a sub I call start/show new form/module
frmExpenses.Initialize("frmExpenses", 1280, 700)
'.......................
Sub frmExpenses_CloseRequest (EventData As Event)
EventData.Consume 'stop form from unloading
'do some stuff first ...
Log("Closing Form Now ...")
frmExpenses.Close
End Sub
But note ... It appears this event will only fire if the form is closed via Form X click.
I have other forms that are closed via Image/Button with a call formName.Close and the Event does not fire.
I have done as you folk suggested (checked the initialization stub). My code is similar to mj's, but only the module Main responds. I will set up a test app and try that just in case I am doing something else that is plain silly. I will let you know what happens.
Thanks - Hilton.
Each afternoon at 3pm I play 9holes of golf, I enjoy the walk. Anyway, on the way there a light bulb switched on in my head - yes the problem is ME.
I have a class that implements my pattern of work and is the engine that modules implement, pass some parameters and then tell it to go. I simply put the code in the module instead of in the class which then informs the module which then cleans up.