Languages

Menu
Sites
Language
Touch events are not called for underneath controls

Hello,

Let's say I have two controls: a button and a transparent panel. The panel is on top of the button. The problem is that the panel swallows all touch events and I cannot interact with the button. So I wonder if there's a proper way to solve this. Should I have to listen to the events from the panel and manually forward to the button?

Thanks for any help.

Edited by: Brock Boland on 17 Mar, 2014 Reason: Paragraph tags added automatically from tizen_format_fix module.

Responses

7 Replies
Siddharth Singh
You can keep your button on top of the panel...if you can. You can use SetControlAlwaysOnTop() method for the same.
le thanh dinh
Thanks for your comment. However, it will not solve my problem because I need the panel on top of the button, either by parent-child or z-index relation. In my case, that z-index/parent-child relation is needed for layout UI purpose but I still need to handle the touch events. I have this situation quite often and have not figured it out how to make it properly and easily. I suppose any controls should automatically forward its event to below controls (event below means z-index or child) as in many other platforms.
Alex Dem
Hi, You are able to add ITouchEventListener on panel and get coordinates pressed point OnTouchPressed/OnTouchReleased. But I did not face with api to trigger button press. Alexey.
le thanh dinh
Hi Alex, Thanks. So does it mean that I have to sub-class the panel to add the event listener? I just think it would be better if the panel just stood there as a drawing object instead of a control just hide everything below it. Anyway, I'm thinking to not use the panel and try some drawing with visual element or canvas instead.
Alex Dem
Yes I mean this. But you will not able to initiate button press in any case( Alexey.
le thanh dinh
I figured it out how to do it, properly I guess. Actually, for image controls which only serve as UI building, I should use VisualElement class instead of Panel. For example before I sub-class the ImagePanel (whose sole purpose to display an image) from Panel and it got problem as mentioned above. Instead I sub-class it from VisualElement and my problem is solved. Now I can still draw images and place them around, even on/overlap other controls, such as buttons, scroll panels, etc. by changing the z-order accordingly but they will not consume my precious events as before.
Siddharth Singh
Thanks for sharing!