Problem description
'focus' event on tabGroup it's triggered also when opening a child window when using an activity indicator
Steps to reproduce
Run the sample code.
'focus' event it's correctly triggered when opening the tabGroup.
Then click on the 'Child window'. activity indicator should appear. Then, when also win2 it's opened, the focus event on the tabGroup it's triggered again.
On iOS only the first event it's triggered. Also on MobileWeb it's correctly being triggered only the first one if we just remove the activity indicator.
var tg = Ti.UI.createTabGroup();
Ti.UI.backgroundColor = 'white';
var win1 = Ti.UI.createWindow({
backgroundColor: 'blue'
});
var clikButton = Titanium.UI.createButton({
title:'Child window',
backgroundImage : 'none',
backgroundColor: 'black',
top : 15,
height:41,
font: {
fontFamily:'Helvetica Neue',
fontWeight:'bold',
fontSize:19
},
color: '#FFFFFF'
});
win1.add(clikButton);
var win2 = Ti.UI.createWindow({
backgroundColor: 'yellow',
fullscreen: false
});
var activityIndicator = Titanium.UI.createActivityIndicator({
height:'100%',
width:'100%',
message:'Loading...',
font:{size:8},
color:'white',
style:''
});
var activityView = Ti.UI.createView({
zIndex:10,
height:'20%',
width:'31.25%',
borderRadius:10,
backgroundColor:'black'
});
var activityWindow = Ti.UI.createWindow({
width:'100%',
height:'100%'
});
activityView.add(activityIndicator);
activityWindow.add(activityView);
clikButton.addEventListener('click', function () {
activityIndicator.show();
activityWindow.open();
// do some work that takes 1 second
setTimeout(function(){
tab1.open(win2);
activityIndicator.hide();
activityWindow.close();
}, 1000);
});
var tab1 = Ti.UI.createTab({
title: 'tab1',
window:win1
});
tg.addTab(tab1);
tab1.addEventListener('focus',function(){
var alertDialogue = Ti.UI.createAlertDialog({
title:'alert'
});
alertDialogue.show();
});
tg.open();
This is correct behavior because your example is opening the "activityWindow" which blurs the TabGroup.