B4J Question Common Sub nnn_Action event always returns the last dynamically created item's ID what is the wrong?

Christos Dorotheou

Member
Licensed User
Longtime User
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 400
#End Region

Sub Process_Globals
Private fx As JFX
Private MainForm As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show

AddFields
End Sub

Sub AddFields
Dim z As Int
Dim intLeft As Int = 50
Dim intTop As Int = 50

Dim tf As TextField

For z = 1 To 4
tf.Initialize("txtFld")
tf.Id = z
tf.Tag = "txtFld"&z
tf.Text = z
MainForm.RootPane.AddNode(tf,intLeft,intTop,200,30)
intTop = intTop + 35
Next
End Sub

Sub txtFld_Action
Dim txtfld As TextField
txtfld = Sender
Log(txtfld.Id)
End Sub
 
Top