TiDraggable icon indicating copy to clipboard operation
TiDraggable copied to clipboard

Click events for Ti.Draggable not firing?

Open dirkesquire opened this issue 11 years ago • 4 comments

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 avatar Dec 23 '12 19:12 dirkesquire

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.

dirkesquire avatar Dec 23 '12 20:12 dirkesquire

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

vpsouza avatar May 11 '13 10:05 vpsouza

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

bitfabrikken avatar May 11 '13 11:05 bitfabrikken

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...

vpsouza avatar May 14 '13 00:05 vpsouza