I noticed something. When my a variable contains an underscore, events won't be called anymore, like in this example:
B4X:
Sub Process_Globals
Private fx As JFX
Private Main_Form As Form
End Sub
Sub AppStart (Form1 As Form, Args() As String)
Main_Form = Form1
Main_Form.RootPane.LoadLayout("Main") 'Load the layout file.
Main_Form.Show
End Sub
Sub Main_Form_CloseRequest (EventData As Event)
Log("Close request")
End Sub
Sub Main_Form_Closed
Log("Closed")
End Sub
Sub Main_Form_FocusChanged (HasFocus As Boolean)
Log("Focus Changed: " & HasFocus)
End Sub
Sub Main_Form_IconifiedChanged (Iconified As Boolean)
Log("Iconified Changed: " & Iconified)
End Sub
There is no bug here. The variable name is not important. The "event name" property of the main form is always MainForm.
See this small test:
B4X:
Sub AppStart (Form1 As Form, Args() As String)
Main_Form = Form1
Main_Form.RootPane.LoadLayout("Main") 'Load the layout file.
Main_Form.Show
Dim b As Button
b.Initialize("b_b")
Main_Form.RootPane.AddNode(b, 0, 0, 100, 100)
End Sub
Sub b_b_Action
Log("dd")
End Sub