Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7928] MobileWeb: label doesn't support click or singletap event

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-03-13T17:13:48.000+0000
Affected Version/sRelease 2.0.0
Fix Version/sRelease 2.0.0, Sprint 2012-06
ComponentsMobileWeb
Labelsqe-port
ReporterTim Poulsen
AssigneeBryan Hughes
Created2012-03-08T11:03:55.000+0000
Updated2012-08-09T14:28:43.000+0000

Description

Expected results

Clicking the label should display the alert. Using the singletap event should also work.

Actual results

Works in iOS/Android, no alert displayed in Mobile Web. Code works with singletap in native also, but not MW.

var label1 = Titanium.UI.createLabel({
	color:'#999',
	text:'Mobile Web Rocks!',
	font:{fontSize:20,fontFamily:'sans-serif'},
	textAlign:'center',
	width:'auto'
});
label1.addEventListener('click', function() {
	alert('label was clicked');
});

win1.add(label1);

Attachments

FileDateSize
app.js2012-03-12T14:15:52.000+00001242

Comments

  1. Bryan Hughes 2012-03-08

    This is the expected behavior. The same thing happens on iOS last time I checked. The "touchEnabled" property controls whether or not a control receives touch events, and it defaults to false in labels. Set it to true to receive events.
  2. Bryan Hughes 2012-03-08

    I stand corrected. It looks like the behavior was changed in iOS and we weren't informed of this change.
  3. Tim Poulsen 2012-03-08

    OK, that would have surprised me if required. I've never heard of that requirement on iOS or Android and have added touch events to labels quite frequently (demos during training a lot). I can confirm that setting touchEnabled=true works. So it looks like you just have to flip the default.
  4. Bryan Hughes 2012-03-12

    Pull Request: https://github.com/appcelerator/titanium_mobile/pull/1644
  5. Lokesh Choudhary 2012-08-09

    Tested On: Titanium studio : 2.1.1.201207271312 SDK version : 2.2.0.v20120809014911 Android 4.0.4 - default ,chrome 18.0 Iphone 4.3.5 - safari mobile Mountain lion(10.8) - chrome 21.0,safari 6,firefox 14.0.1
  6. Lokesh Choudhary 2012-08-09

    Tested On: Titanium studio : 2.1.1.201207271312 SDK version : 2.2.0.v20120809014911 Android 4.0.4 - default ,chrome 18.0 Iphone 4.3.5 - safari mobile Mountain lion(10.8) - chrome 21.0,safari 6,firefox 14.0.1

JSON Source