[AC-2778] Android: window open events are not firing when windows belong to tabs
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2012-03-28T16:05:12.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | n/a |
Reporter | Shannon Hicks |
Assignee | Mauro Parra-Miranda |
Created | 2012-03-21T12:53:17.000+0000 |
Updated | 2016-03-08T07:47:41.000+0000 |
Description
The open event is not firing reliably. Here's a summary of what happens on each platform:
iOS: win1 open event fires when the app opens, win2 open event fires when you switch to it's tab
Android Ti 1.8.1: no open events fire
Android Ti 1.8.2: no open events fire
Android Ti 2.0 CI: win1 open event fires when the app opens, win2 open event never fires
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
win1.addEventListener('open',function(){
alert('win1 opened');
});
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'
});
win2.addEventListener('open',function(){
alert('win2 opened'); // this event does not fire on Android
});
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);
//
// add tabs
//
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
// open tab group
tabGroup.open();
I experience the same problematic behavior. Work around is to capture the windows focus event and use a boolean to make sure your code is run only once.
Closing since it's a dup.