{ "id": "62257", "key": "TIMOB-1625", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11225", "name": "Release 1.5.0", "archived": true, "released": true, "releaseDate": "2010-12-14" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T01:56:41.000+0000", "created": "2011-04-15T02:57:43.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android", "defect", "eventlistener", "view" ], "versions": [], "issuelinks": [], "assignee": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-04-17T01:56:41.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{html}

If you attach a click event to a view with\naddEventListener(\"click\",....), the event does not fire unless\nyou've created children objects inside the view.

\n

Example (this works fine on iOS but not on Android):

\n

var myView = Ti.UI.createView({

\n
\ntop:100,\nleft:100,\nheight:40,\nwidth:40,\nbackgroundColor:'red'\n
\n

});

\n

win1.add(myView);

\n

myView.addEventListener(\"click\",function(e) {

\n
\nalert(\"you tapped the red box!\");\n
\n

});

\n
\n

However, if you add a label to the view,
\nclicking on the label fires the event:

\n
\n

var myView = Ti.UI.createView({

\n
\ntop:100,\nleft:100,\nheight:40,\nwidth:40,\nbackgroundColor:'red'\n
\n

});

\n

var myLabel = Ti.UI.createLabel({text:\"AAA\"});
\nmyView.add(myLabel);

\n

win1.add(myView);

\n

myView.addEventListener(\"click\",function(e) {

\n
\nalert(\"you tapped the red box!\");\n
\n

});

{html}", "attachment": [], "flagged": false, "summary": "events attached to a view not working in Android", "creator": { "name": "burggraf", "key": "burggraf", "displayName": "Burggraf", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "burggraf", "key": "burggraf", "displayName": "Burggraf", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "126216", "author": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

I ran into this bug today while attempting to attach a click\nhandler to a View to create a larger touch target for a fixed-size\nicon shown via an ImageView.

\n

Just want to add that the parent View's events do fire when\ntapping on the child view (eg the label in the example above, or my\nImageView when I tried making it a child of the larger View) but\nstill not on the rest of the parent View.

\n

I worked around this by instead placing a fixed-size Label with\nno text on top of the ImageView, and putting the click event on the\nlabel.

{html}", "updateAuthor": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:57:44.000+0000", "updated": "2011-04-15T02:57:44.000+0000" }, { "id": "126217", "author": { "name": "burggraf", "key": "burggraf", "displayName": "Burggraf", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

We've noticed a temporary workaround until this is fixed. The\n\"touchStart\" event DOES fire, so if you use that instead of the\n\"click\" event, you can get the same behavior. (Technically click\nand touchStart are a bit different, if you were to touch and drag\noff the object, then release. But for the most part, using\ntouchStart does the trick for us.)

{html}", "updateAuthor": { "name": "burggraf", "key": "burggraf", "displayName": "Burggraf", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:57:44.000+0000", "updated": "2011-04-15T02:57:44.000+0000" }, { "id": "126218", "author": { "name": "hal", "key": "hal", "displayName": "hal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

In Android I think this issue has something to do with\nsetClickable() returning true for complex views but false for\nsimple views.
\nThe easiest workaround is to use the borderRadius property to force\nthe view to be complex:

\n

borderRadius:0

\n

Then you can use the click event as normal.

{html}", "updateAuthor": { "name": "hal", "key": "hal", "displayName": "hal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:57:45.000+0000", "updated": "2011-04-15T02:57:45.000+0000" }, { "id": "126219", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Also reported in #952

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:57:45.000+0000", "updated": "2011-04-15T02:57:45.000+0000" }, { "id": "126220", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

(from [7b6449b75f82462bd18c1c4776ef67f014e18829])\n[#952\nstate:fixed-in-qa][#1625 state:fixed-in-qa] refactored click\nhandling and removed special cases that weren't needed. Note if a\nview doesn't handle a click Android search up through all\ncomponents under the touch/click point to find one that will. If\nyou want to stop other views from getting a click (e.g. full screen\nloading view) just set an no-op click handler on the topmost view\n\nhttp://github.com/appcelerator/titanium_mobile/commit/7b6449b75f824...

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:57:45.000+0000", "updated": "2011-04-15T02:57:45.000+0000" }, { "id": "126221", "author": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

g1, 1.6, 2.2 simulator. 1.4.2.5935b3

{html}", "updateAuthor": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:57:45.000+0000", "updated": "2011-04-15T02:57:45.000+0000" }, { "id": "126222", "author": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

confirmed - 1.4.2.5935b3 g1 1.6, sim with 2.2. Checked on iOS\n4.1

{html}", "updateAuthor": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:57:46.000+0000", "updated": "2011-04-15T02:57:46.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }