[TIMOB-9120] Ti.App.addEventListener does not get the object passed from Ti.App.fireEvent
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Open |
Resolution | Unresolved |
Affected Version/s | Release 2.0.1, Release 3.1.0 |
Fix Version/s | n/a |
Components | iOS |
Labels | n/a |
Reporter | Qing Gao |
Assignee | Unknown |
Created | 2012-05-11T17:32:58.000+0000 |
Updated | 2018-02-28T20:04:25.000+0000 |
Description
Repro Step
Create a project to run the following code.
Expected Result: The console out put should print out an object.
Actual Result: [INFO] [object Object] undefined
var tabGroup = Ti.UI.createTabGroup({
backGroundColor:'red'
});
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win1
});
var label1 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 1',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
win1.add(label1);
//
// create controls tab and root window
//
var win2 = Titanium.UI.createWindow({
title:'Tab 2',
backgroundColor:'#fff'
});
var tab2 = Titanium.UI.createTab({
icon:'KS_nav_ui.png',
title:'Tab 2',
window:win2
});
var label2 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 2',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
win2.add(label2);
tab2.addEventListener('focus',function(e){
var obj = {'tab': tab2, 'win':win2};
Ti.App.fireEvent('openTab', obj);
Ti.API.info('event is fired');
});
//
// add tabs
//
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
Ti.App.addEventListener('openTab', function(obj) {
Ti.API.info(obj +' '+obj.tab);
});
// open tab group
tabGroup.open();
I'm not sure is this issue valid. According to some info, argument to "fireEvent" method should be JSON serializable object and Titanium objects are not for sure. I am not sure about this, because functions are not serializable, while they can be passed to "fireEvent" method. Can someone bring some light to this subject? Thanks.
Issue reproduces Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 Titanium SDK version: 3.0.2 iOS iPhone Simulator: iOS SDK version: 6.0