Panel: is it transparent to underlying views?

Beja

Expert
Licensed User
Longtime User
friends,

I put a few buttons on Activity, blanket them allover with a panel then put
new buttons on the panel, making their parent Panel1. but to my surprise,
when I clicked on an area on the panel, where a button is hiding behind in the
activity, that button's code is executed.
I thought Panels are containers and can not act on views' events
that don't belong to them.

Any help?
Thanks in advance.
 

mc73

Well-Known Member
Licensed User
Longtime User
You need to consume the panel click event otherwise it will go through to underlying views.
You can do this by simple creating a Panel_Touch sub. I am not sure whether or not you need to return True/False, but surely you can experiment with that.

I used to add the panel_touch, but in later versions, I think that simply a panel_click will consume the event. Works for me, but who knows of course :)
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Thanks guys so much..
So I will exitsub whenever the panel is touched!
 
Upvote 0

merlin2049er

Well-Known Member
Licensed User
Longtime User
Hmm, how about some sample code? I think I tried adding a panel_click sub in my code, but it wasn't consumed.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
This is an old thread !
I think I tried adding a panel_click sub in my code, but it wasn't consumed.
What exactly did you do ?
Without seeing what you have done and how impossible to give you a concrete advice !
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
B4X:
sub panel_click
dim i as int=0
i=i+1
end sub

Yet easier:

B4X:
sub panel_click
Return
end sub
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
check the attached test project
 

Attachments

  • clickings.zip
    7.2 KB · Views: 251
Upvote 0

klaus

Expert
Licensed User
Longtime User
You can even simply use:
B4X:
Sub Panel1_Click

End Sub
On my device your code works as expected !
If you click on the button in an area where the button is covered by the panel nothing happens.
If you click on a visible area of the button, the Button1_Click event is, of cours, fired.
 
Upvote 0
Top