Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8067] MobileWeb: Window - The focus event isn't firing each time and reports undefined for the source.name

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-04-17T22:12:04.000+0000
Affected Version/sRelease 2.0.0
Fix Version/sRelease 2.0.0, Sprint 2012-06
ComponentsMobileWeb, Windows Hybrid
Labelsqe-mw020912, qe-port
ReporterMichael Pettiford
AssigneeBryan Hughes
Created2012-03-16T15:18:43.000+0000
Updated2014-04-17T22:12:04.000+0000

Description

Steps to reproduce: 1. Create a default mobile web app and change the app.js code to the following:
var tabGroup = Ti.UI.createTabGroup();

var win1 = Ti.UI.createWindow({
	name: "win 1"
});
var tab1 = Ti.UI.createTab({
	name: "Tab 1",
	title:'Tab 1',
	window:win1
});

var win2 = Ti.UI.createWindow({
	name: "win 2",
	title:'Tab 2',
	backgroundColor:'#fff'
});
var tab2 = Ti.UI.createTab({
	name: "Tab 2",
	title:'Tab 2',
	window:win2
});

tabGroup.addTab(tab1);
tabGroup.addTab(tab2);

tabGroup.addEventListener('focus', function(e){
	Ti.API.info('-------------> tabGroup focus event fired! - ' + e.source.name);
});
tab1.addEventListener('focus', function(e){
	Ti.API.info('-------------> tab1 focus event fired! - ' + e.source.name);
});
tab2.addEventListener('focus', function(e){
	Ti.API.info('-------------> tab2 focus event fired! - ' + e.source.name);
});
win1.addEventListener('focus', function(e){
	Ti.API.info('-------------> win1 focus event fired! - ' + e.source.name);
});
win2.addEventListener('focus', function(e){
	Ti.API.info('-------------> win2 focus event fired! - ' + e.source.name);
});

tab1.addEventListener('blur', function(e){
	Ti.API.info('**************> tab1 blur event fired! - ' + e.source.name);
});
tab2.addEventListener('blur', function(e){
	Ti.API.info('**************> tab2 blur event fired! - ' + e.source.name);
});
win1.addEventListener('blur', function(e){
	Ti.API.info('**************> win1 blur event fired! - ' + e.source.name);
});
win2.addEventListener('blur', function(e){
	Ti.API.info('**************> win2 blur event fired! - ' + e.source.name);
});

tabGroup.open();
2. Run the app 3. Tap between the two tabs Actual result: One focus event is fired with an undefined e.source.name Expected result: Focus events are fired each time a user switches between tabs

Comments

  1. Bryan Hughes 2012-03-19

    Note: the undefined e.source.name is expected. When the tabgroup fires a focus event, the source is the tabgroup, which you didn't specify a name for. I confirmed the same behavior on iOS. You can use e.tab to access the focused tab.
  2. Bryan Hughes 2012-03-19

    Pull Request: https://github.com/appcelerator/titanium_mobile/pull/1747
  3. Lokesh Choudhary 2012-08-14

    Verified fix on: Titanium studio : 2.1.1.201207271312 SDK version : 2.2.0.v20120814103312 Mountain lion(10.8) - chrome 21.0,safari 6,firefox 14.0.1

JSON Source