Android Question Get Touch Event of a Label

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi everyone, i was wondering, there is a way to retrive the _Touch event from a label?

Thanks in advance
 

Mike1970

Well-Known Member
Licensed User
Longtime User
Put it inside a transparent panel.

Actually i need it just for this reason ahahha.
I have a panel, with a label inside, i need only the the panel touch event. But if i tap on the label (lblNomeZona) the panel_touchevent (pnlWhiteShadow) does not fire :(

Cattura.PNG
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I created a transparent panel with a label inside it as Erel instructed you and I was able to get the Panel touch event to fire:
B4X:
Private Panel1 As B4XView  'in globals
    Private Label1 As Label
    Private xui As XUI

Activity.LoadLayout("Layout1")  'in activity_create
    Panel1.SetColorAndBorder(xui.color_transparent,4dip, xui.Color_Magenta,5dip)

Private Sub Panel1_Touch (Action As Int, X As Float, Y As Float)
    Label1.Text="Mike1970"
End Sub
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
I created a transparent panel with a label inside it as Erel instructed you and I was able to get the Panel touch event to fire:
B4X:
Private Panel1 As B4XView  'in globals
    Private Label1 As Label
    Private xui As XUI

Activity.LoadLayout("Layout1")  'in activity_create
    Panel1.SetColorAndBorder(xui.color_transparent,4dip, xui.Color_Magenta,5dip)

Private Sub Panel1_Touch (Action As Int, X As Float, Y As Float)
    Label1.Text="Mike1970"
End Sub
I will make a sample.
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User

Attachments

  • TestLabelTouch.zip
    11.6 KB · Views: 289
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
This is not my AutoTextSizeLabel implementation.
You are so smart. How can we tell if it is yours or not. I wish others name them differently. I got so confused.
So what Erel is telling is change this line in the class module :
B4X:
mautopnl = xui.CreatePanel("mautopnl")
to:
B4X:
mautopnl = xui.CreatePanel("")
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
This is not my AutoTextSizeLabel implementation.
It handles the Click event internally.

Set the event name to "":
B4X:
mautopnl = xui.CreatePanel("")
Thanks erel! actually i don't remember where i download that class, then i slighlty modified it to add maxTextSize
However now it works as intended :D
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
This is the one from Erel. Highly recommend it. I have used before. I wish other developers give their libraries distinctive names different than what Erel uses. It is not fair to him. I spent over an hour this morning trying to solve your puzzle so I can help, thinking it was Erel's class module.:
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
This is the one from Erel. Highly recommend it. I have used before. I wish other developers give their libraries distinctive names different than what Erel uses. It is not fair to him. I spent over an hour this morning trying to solve your puzzle so I can help, thinking it was Erel's class module.:
I don't remember why i choosed, the other one, probably the original one gave me problem and i switched to the other.
Also, the Erel's one is cross-platform? or only b4a?
 
Upvote 0
Top