Problem Description
The source of events like click, singletap, are not being reported. Instead, you get random internal information.
Steps to Reproduce
1. Create new mobile project with 3.1.3 in iOS
2. Paste the testcase to app.js
3. Run the app, click on the row.
4. You will see the source.
Testcase
var rowdata = [
{title: 'row_0'},
{title: 'row_1'},
{title: 'row_2'},
];
var win = Ti.UI.createWindow( { backgroundColor: '#FFFFFF' } );
var table = Ti.UI.createTableView( { data: rowdata } );
// Either:
table.addEventListener('singletap', eventArrived);
//table.addEventListener('doubletap', eventArrived);
// Or:
//table.addEventListener('click', eventArrived);
win.add(table);
win.open();
function eventArrived(e) {
alert('Event from table: ' + JSON.stringify(e));
}
Extra info
With singletap and doubletap events, the event contains no row information:
[TRACE] : Event from table: {'x':222,'y':31,'bubbles':true,'type':'singletap','source':{'hideSearchOnSelection':true,'horizontalWrap':true,'searchHidden':false},'cancelBubble':false}
[TRACE] : Event from table: {'x':91,'y':61,'bubbles':true,'type':'singletap','source':{'hideSearchOnSelection':true,'horizontalWrap':true,'searchHidden':false},'cancelBubble':false}
[TRACE] : Event from table: {'x':145,'y':101,'bubbles':true,'type':'singletap','source':{'hideSearchOnSelection':true,'horizontalWrap':true,'searchHidden':false},'cancelBubble':false}
[TRACE] : Event from table: {'x':137,'y':22,'bubbles':true,'type':'doubletap','source':{'hideSearchOnSelection':true,'horizontalWrap':true,'searchHidden':false},'cancelBubble':false}
[TRACE] : Event from table: {'x':130,'y':73,'bubbles':true,'type':'doubletap','source':{'hideSearchOnSelection':true,'horizontalWrap':true,'searchHidden':false},'cancelBubble':false}
[TRACE] : Event from table: {'x':129,'y':100,'bubbles':true,'type':'doubletap','source':{'hideSearchOnSelection':true,'horizontalWrap':true,'searchHidden':false},'cancelBubble':false}
With click events, the event object correctly contains row information:
[TRACE] : Event from table: {'x':122,'section':{'horizontalWrap':true},'row':{'horizontalWrap':true,'title':'row_0'},'index':0,'y':36,'rowData':{'horizontalWrap':true,'title':'row_0'},'searchMode':false,'detail':false,'bubbles':true,'type':'click','source':{'horizontalWrap':true,'title':'row_0'},'cancelBubble':false}
[TRACE] : Event from table: {'x':135,'section':{'horizontalWrap':true},'row':{'horizontalWrap':true,'title':'row_1'},'index':1,'y':9,'rowData':{'horizontalWrap':true,'title':'row_1'},'searchMode':false,'detail':false,'bubbles':true,'type':'click','source':{'horizontalWrap':true,'title':'row_1'},'cancelBubble':false}
[TRACE] : Event from table: {'x':166,'section':{'horizontalWrap':true},'row':{'horizontalWrap':true,'title':'row_2'},'index':2,'y':23,'rowData':{'horizontalWrap':true,'title':'row_2'},'searchMode':false,'detail':false,'bubbles':true,'type':'click','source':{'horizontalWrap':true,'title':'row_2'},'cancelBubble':false}
Expected Result
Row information from singletap, doubletap, and click events (as per current API documentation).
This is critical priority for us. Our app needs to use singletap listeners (instead of click listeners) on our table rows and this bug makes that functionality inoperable. Interestingly, you will note that when the tablerow has elements stacked on top of it, tapping those elements does indeed fire the event with row information. As such, a potential temporary workaround until Appcelerator fix this is to create a full-width transparent view on the table row and then use a custom label instead of a 'title' attribute when building the table row. eg. var row = Ti.UI.createTableViewRow({hasChild: true, height: 44}); // This view ensures that when the row is tapped, the event that is fired contains a 'row' property. Assumedly, you would build this with a transparent background. row.add(Ti.UI.createView({width: '100%', height: 44, backgroundColor: 'yellow'})); // If the view above is not present, tapping this element fires the event with the row property. Tapping elsewhere on the row fires the event without the row property. row.add(Ti.UI.createLabel({ text : 'row_x', left: 7, width: 100, backgroundColor: 'gray' })); var rowdata = [ row ]; ... Note: this workaround still doesn't include the row property in the event if the 'hasChild' arrow is tapped.
Thank you for the report. We will discuss this for inclusion in the next release.
Pull pending against master https://github.com/appcelerator/titanium_mobile/pull/4891
Hi Vishal, When will TI SDK update available with this fix? Thanks.
[~muralinr] Version 3.2.0 as noted in the "Fix Version" field. Likely early December.
Tested and verified the fix with: OSX: 10.8.5 Xcode:5.0 Appcelerator Studio: 3.2.0.201311122338 SDK: 3.2.0.v20131113183932 acs:1.0.7 alloy:1.3.0 npm:1.3.2 titanium:3.2.0 titanium-code-processo:1.0.3 Device: iOS7(v7.0.3)-iPodTouch1
I still see this issue on TI SDK 3.2.0 version. When will this issue be fixed and released? Thanks.
If you still see this issue, please provide a test case that demonstrates it. There may be an edge case we missed.
Here is test case (app.js) and steps to reproduce this issue:
Steps to reproduce this issue: 1. Create a new mobile project for iOS7, with 3.2.0.GA 2. Paste the testcase into app.js 3. Run in the simulator 4. Click on the first row. 5. Click on the second row. 6. Check console, you will see the difference, even if you created the two rows in the same way. Log file when YY label is clicked in TableView: First row output: [INFO] e.row =[object TiUITableViewRow], e.source = [object TiUITableViewRow] Second or any other row is clicked: [INFO] e.row =[object TiUITableViewRow], e.source = [object TiUILabel]
Hello, Is there any update on above test code? When will this issue be fixed? Thanks.
Reopening based on comments
Appc Studio:3.2.1.201401151647 Sdk:3.2.1.v20140117222448 alloy:1.3.1-beta2 titanium:3.2.1(from cli) acs:1.0.11 titanium-code-processor:1.1.0 Osx: Maverick 10.9 Xcode:5.0.2 Device:iPhone5c(v7.0.4) SingleTap and DoubleTap working for tableView. Hence Closing the issue.