touch events ignored on both label and views
Can anyone else confirm this as an actual bug? I've tried creating a view with a label inside it. I've created an event handler for the view to monitor 'singletap' and show an alert. Running it on the emulator and nothing happens when i click the view. I've then tried adding that event to the label. Again no result. I've tried creating a label outside of the view and assigning that the touch result. No effect. Lastly (just to debug if the event handlers are even working) i made an imageView and gave it my touch event. It works as expected.
touchEnabled is true for the view and labels.
So can i add touch events for views and labels to my ever growing list of bugs and limitations in titanium?
Please could someone else test this out and confirm.
5 Answers
-
Accepted Answer
There was a bug in the CI build a couple of days ago where views were only touchable if they had a click listener. That has been fixed in the newer CI builds.
-
This bug is still there. If I add a "click" event listener on Scrollable view I can't scroll it on ipad. It works fine on Android. I am using latest titanium studio Titanium Studio, build: 1.0.8.201201262211.
Thanks,
Sree -
Looks like this is a secret inconsistency between iPhone and Android platforms. On iPhone, this works fine (note these code snippets are being run under a tabGroup like KitchenSink's framework for examples):
var win = Ti.UI.currentWindow; win.title = 'Platform Events'; var view = Ti.UI.createView(); win.add(view); var lab = Ti.UI.createLabel({ text: 'Touch me in order to test Events', textAlign: 'center' }); view.add(lab); lab.addEventListener('singletap', function(e) { alert('I got a singletap!'); }); lab.addEventListener('doubletap', function(e) { alert('I got a doubletap'); });
The event is caught, and the alert will pop up on iPhone for both singletap and doubletap. But, not on android! However, if you add handling for the 'click' event, android comes alive. i.e.:
var win = Ti.UI.currentWindow; win.title = 'Platform Events'; var view = Ti.UI.createView(); win.add(view); var lab = Ti.UI.createLabel({ text: 'Touch me in order to test Events', textAlign: 'center' }); view.add(lab); lab.addEventListener('singletap', function(e) { alert('I got a singletap!'); }); lab.addEventListener('doubletap', function(e) { alert('I got a doubletap'); }); // //add click handling to kick android in the pants // lab.addEventListener('click', function(e) { alert('I got a click!'); });
Hope that helps.
-
I have a similar problem to alex.
I have a View that contains a Label and and ImageView.
I have 3 event listeners attached to the View (singletap, touchstart and touchend)
The events are fired on iphone as expected and I get the proper results.
They do not seem to work on Android emulator ( Android 2.3.1). The click event will work on Android though.
I thought it could be the emulator configuration so I added in touchscreen functionality into the emulator config but still no correct behavior.
I am using 1.8.1 of Titanium.
-
There was a bug in the CI build a couple of days ago where views were only touchable if they had a click listener. That has been fixed in the newer CI builds.