01-02-2013 07:18 AM - edited 01-02-2013 07:22 AM
Hi, I am wondering how exactly OverlapTouchPolicy works. I've read lot of the threads about it on this forum and the documentation but it is still confusing on how the touch is handled on overlapped controls.
On the last post of the above thread, the asker thinks that OverlapTouchPolicy is set to Allow on the top control so that the control underneathe it will receive the touch event but the other person didn't answer. However, by the way the original question was answered, the OverlapTouchPolicy should be set on the control underneathe...? Why? How does that logic work? Why did the answerer commented out the onClicked event on the ImageButton and only handled touch event on the label using onTapped?
And also, could someone explain what TouchPropagation and each of its options do? What is the relationship between TouchPropagation and OverlapTouchPolicy?
01-02-2013 11:03 PM
did you read the documentation: https://developer.blackberry.com/cascades/document
the documentation explains it pretty well with some example...although i do agree it may be lacking!
to make it short:
- as the word says, if more than one of your components are overlapping each other on the screen, they will 'fight' to get the touch event. To make sure, the component that is listening for the onTouch event properly receives the event, set all the overlapping components to OverlapTouchPolicy.Allow
- ex. had a lot of issues with this when using DockLayout....especially when you use ActivityIndicator with a DockLayout to center the activity animation!!!! HINT: make sure your activity indicator is always set to OverlapTouchPolicy.Allow
- again as explained in the doc (although from experience, it doesn't always work properly in some scenarios!).
- overlaptouchpolicy is for overlapping components where this one (touch propagation mode) is for child-parent (hiearchical) components
- usually the case in your QML with huge hierarchy on containers within containers within imageview within...
- if a component/container is set to TouchPropagationMode.None, touch propagation stops at this component. This element simply won't receive a touch() or touchCapture() event, and neither will its children.
Regarding the linked post, if you read the above documentation, you should see how wrong that post was...
If the docs or my brief explanation above is still not enough, then post some specific questions for us to help you!