'
Dim TextField1 as TextField
Dim TextField2 as TextField
Dim TableView1 As TableView
'
ref (TextField1)
ref (TextField2)
ref (TableView1)
'
'
'
'
Private Sub ref (t As Object)
Dim r As Reflector
r.Target = t
r.AddEventHandler("keypressed", "javafx.scene.input.KeyEvent.KEY_PRESSED")
End Sub
'
Private Sub keypressed_event (e As Event)
Log("How to know the object? ")
Dim tt As Object = Sender
Log(GetType(tt)) 'is that correct?
'
Dim KE As Reflector
KE.Target = e
Dim KeyCode As String
KeyCode = KE.RunMethod("getCode")
Log(KeyCode)
End Sub
Add a Tag for each view, and then you can know what the object is.
B4X:
Dim TextField1 as TextField
TextField1.Tag="TF1"
ref (TextField1)
...
Private Sub keypressed_event (e As Event)
Log("How to know the object? ")
Dim tt As B4XView = Sender
Log(tt.Tag) 'This is correct
'...
End Sub
You could use the ID field of most nodes, but it takes a bit more code to set and use
B4X:
Dim TextField1 as TextField
...
TextField1.as(JavaObject).RunMethod("setId",array("TextField1")) ' needed for each control you want
...
Private Sub keypressed_event (e As Event)
Log("How to know the object? ")
Dim tt As JavaObject = Sender
Log(tt.RunMethod("getId",null))
'...
End Sub