B4J Question Access label properties from javaObject

rossati

Active Member
Licensed User
Longtime User
Hi
I have a tableview that contains a column of labels that can be clicked. These labels have a tag that I am not able to see in the event function, see below:
B4X:
Sub Cancel_MouseClicked (EventData As MouseEvent)    ' delete event

    Dim jo As JavaObject = EventData
    Dim target As JavaObject = jo.RunMethod("getTarget", Null)
'    Dim l As Label = target
'    Log(l.tag)
'    Dim text As String = target.RunMethod("getText", Null)
...
End Sub
My be the problem is because the getTarget method returns a LabeledText instead of Label.
Thanks for any suggestion.
Giovanni Rossati
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
If the cancel mouseclicked event is from the label then you only need to do.
B4X:
Sub Cancel_MouseClicked (EventData As MouseEvent)    ' delete event
Dim lbl as label = sender

Sender is a special keyword, then more than one object invokes the same event you can now which object triggered it. The only restriction is that it must be the first line after the sub
 
Upvote 0
Top