Problem Description
Tabgroup's focus event is not working as with iOS.
Actual Results
The focus event is never fired
Expected results
The focus event should fire.
Testcase
1. Create new mobile Project.
2. Paste app.js:
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
var win = Titanium.UI.createWindow({
backgroundColor:'white',
title:'window',
barColor:'#ff7b01',
top:0,
navBarHidden:false
});
/* win.addEventListener('focus',function(){
alert('focus');
}); */
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win
});
var tab2 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 2',
window:win
});
var titleImage = Ti.UI.createView({
width:94,
height:24,
backgroundImage:'/images/header/ing_logo_header.png',
});
win.titleControl = titleImage;
//win.open();
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
tabGroup.open();
tabGroup.addEventListener('focus',function(){
alert('focus tabs fired')
});
tabGroup.addEventListener('click',function(){
alert('click fired')
});
3. Test this code in iOS, compare with this code in MobileWeb.
Mobile Web does not blur and re-focus the TabGroup when you change a tab because Mobile Web does not bubble events like iOS. Frankly, blurring and re-focusing the TabGroup when a tab is switched is pointless. Use the "focus" event on a TabGroup to know when a window is closed and the TabGroup regains focus. Use the "click" event on TabGroup to know when a tab has changed. Listen on a specific Tab to know when that Tab is clicked, focused, or blurred.
I fixed events on TabGroups and Tabs in TIMOB-9176. The focus event for a TabGroup is fired either when the TabGroup is opened or when a Window is closed and the TabGroup regains focus. The TabGroup should not blur and re-focus every time you change tabs. That's a bug with iOS and Android. I'm working with Josh from the Android team to come up with a consensus with this. As of right now, Mobile Web's implementation is not bound to change for v2.1.
Closing as will not fix
Closing as will not fix