I hope I'm not adding confusion, and I'll admit to being a rank newbie at B4J (and B4A) but here's what I have gotten to work after a fashion.
I have a Layout1 for my MainForm. It just has a Button and a TextField. When you click the Button it should "raise a dialog" (another form) used to request a "name" (just some text).
Then I have a class FetchName that loads a Layout2 as its SubForm. This has a TextField and a Button. When displayed the user should enter a "name" into the TextField and click the Button.
After this, the SubForm disappears and in Main the entered value is retrieved and then displayed in the MainForm's TextField.
So very trivial, or so I thought.
Here is what I have:
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private btnGetName As Button
Private txtName As TextField
Private FetchName As FetchName
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
FetchName.Initialize
MainForm.Show
End Sub
Sub btnGetName_Action
FetchName.Fetch
End Sub
Sub Ok
txtName.Text = FetchName.Name
End Sub
Sub Class_Globals
Private fx As JFX
Private SubForm As Form
Private txtName As TextField
Private btnOk As Button
End Sub
Public Sub Initialize
SubForm.Initialize("SubForm", -1, -1)
SubForm.RootPane.LoadLayout("Layout2")
End Sub
Public Sub Fetch
txtName.Text = ""
SubForm.Show
End Sub
Sub btnOk_Action
txtName.RequestFocus 'Move focus here for next Fetch request.
SubForm.Close
Main.Ok 'Callback to Main.
End Sub
Sub getName As String
Return txtName.Text
End Sub
This sorta kinda works except of course "in real life" you'd want the dialog SubForm to be
modal and I haven't a clue how to make that happen.
Also I had to sort of kludge in a hard-coded callback into Main since I haven't figured out how to implement and raise events in a B4J Class.
But I do feel like I'm missing something (probably a
lot).