pec1985 / TiDraggable

Native iOS and Android modules for Appcelerator's Titanium Mobile
74 stars 75 forks source link

Click events for Ti.Draggable not firing? #3

Open dirkesquire opened 11 years ago

dirkesquire commented 11 years ago

I have a screen with two boxes in Titanium. I am using the Ti.Draggable module to allow the box to be dragged around the screen. I create my draggable objects with drag.createView() and I know that I can add an event listener for the 'start' and 'end' events for when dragging starts and stops. However the normal click and dblclick events seem to not be working anymore. In the example below I have two boxes: A green box and a blue box.This demo shows how the green box responds normally to click and dblclick events. The blue box does not. However the blue box does support dragging. Question: How do I listen to a click event on the blue box?

var self = Ti.UI.createView();
var drag = require('ti.draggable');

var greenbox = Ti.UI.createView({
    top: 50,
    left: 0,
    width: 100,
    height: 100,
    backgroundColor:'#99FF66'
});
self.add(greenbox);

var bluebox = drag.createView({
    top: 50,
    left: 110,
    width: 100,
    height: 100,
    backgroundColor:'#66CCFF'
});
self.add(bluebox);

greenbox.addEventListener('click', function(e) {
    alert('click');
});

greenbox.addEventListener('dblclick', function(e) {
    alert('dbl click');
});

bluebox.addEventListener('click', function(e) {
    alert('click');
});

bluebox.addEventListener('dblclick', function(e) {
    alert('dbl click');
});

return self;
dirkesquire commented 11 years ago

Update: I notice that it seems to be working fine in iOS so it is just in Android that the click events are not firing.

vpsouza commented 11 years ago

So, i need to solve this issue too. For Android, other events else touch start or move not fringed.

bitfabrikken commented 11 years ago

I think this is a general Android Titanium issue, a bug that's been existing for years now. When you modify the transform of something that has e.g. a click eventlistener attached, the eventlistener doesn't move with it.

For instance, create a square view, add a click eventlistener to it, then modify its transform by scaling it up 100%. The view will only react to clicks on the original, untransformed area. This also happens with translate and rotate. Very frustrating issue, and Appcelerator doesn't seem to want to fix it, as it's been marked "high" in JIRA for years. The ticket is here: https://jira.appcelerator.org/browse/TIMOB-6304

vpsouza commented 11 years ago

it's strange... draggable views can listen to longpress events... but when i make a simple click, it does a longpress and a start was throwed too. i think there's a bug of Draggable...