20 Jan 2014 11:58 AM #1
Unanswered: Ignore Second Touch?
I have some custom drag and droppable elements in my sencha touch app. A bug occurs when I'm dragging the item and I use another finger to touch the item I'm dragging (it seems a drop event occurs at that moment?). I was wondering if it is possible to just ignore any additional touches that occur on my object if I'm already dragging it.
21 Jan 2014 2:33 AM #2
Having a look at the source code for Ext.util.Draggable which you can see here: http://docs.sencha.com/touch/2.3.0/source/Draggable2.html#Ext-util-Draggable
take a look at the initDragStart method. This sets .dragging = true; on the draggable. Likewise, when the drag ends, in onDragEnd, this property is set to false. So on your tap event listener, get the element's draggable and test this property. (use getDraggable() on the element to get the instance of Ext.util.Draggable). If it's true, then obviously you want to return out of the listener without doing anything.
I know it's not ideal form to access what is a hidden property like this, but it's the best solution and perhaps the best fix might be for Sencha to expose this .dragging as a config on the Ext.util.Draggable, as it's a useful thing to be able to look at.
21 Jan 2014 8:17 AM #3
I tried this solution, but the problem is that once second tap occurs, it also does a dragEnd event, which drops my element. I'm not sure how I can tell the difference between a second touch triggering the dragEnd event or the first touch actually releasing the element.
21 Jan 2014 8:22 AM #4
I see what you mean. To be honest this is what I would do:
1. Not worry about it too much. I would imagine most users would not change from 1 to 2 fingers during a drag and if they did, and the element dropped, they'd know not to do it again.
2. File a bug in the bugs forum with Ext.util.Draggable. Native dragging behavior on iOS does allow the addition of a finger during a drag without cancelling it, so IMO Sencha should modify the behavior of draggable to match (at least on iOS - I didn't check what happens on Android)
22 Jan 2014 11:41 AM #5Get more personalized support via a support subscription.
Want to learn Sencha Touch 2? Check out
Sencha Touch in Action
Need more help with your app? Hire Sencha Services firstname.lastname@example.org
When posting code, please use BBCode's CODE tags.
Need to include a test case use:
The official Sencha Fiddle