Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-4345] Android: focus and blur events don't fire on window with url

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-11-05T14:44:24.000+0000
Affected Version/sRelease 1.7.0
Fix Version/sSprint 2011-32, Release 1.8.0
ComponentsAndroid
Labelsn/a
ReporterJon Alter
AssigneeAlan Vaghti
Created2011-06-07T13:19:43.000+0000
Updated2011-11-05T14:44:24.000+0000

Description

The focus and blur events are not fired on a window that is opened using the url property. If you remove the url property they work fine. In app.js, if you comment out the url property, and uncomment openButton then focus and blur will work. Step 1: Run the code below Step 2: Notice that focus and blur do not show in your console as you open click open and close. Step 3: In app.js, comment out the url property, and uncomment openButton. Step 4: Run the app again. Step 5: Notice that focus and blur events show up in your console, when you click open and close.
var tabGroup = Ti.UI.createTabGroup();

var win1 = Ti.UI.createWindow({
	backgroundColor: 'blue',
	url: 'win1.js'
});
win1.addEventListener('blur', function(e){
	Ti.API.info('blur');
});
win1.addEventListener('focus', function(e){
	Ti.API.info('focus');
});
// var openButton = Ti.UI.createButton({
// 	title:'open',
// 	height: 50,
// 	width: 200
// });
// win1.add(openButton);
// 
// openButton.addEventListener('click', function(e){
// 	Ti.App.fireEvent('openwin2');
// });

var tab1 = Ti.UI.createTab({
	window: win1
});
tabGroup.addTab(tab1);
tabGroup.open();

Ti.App.addEventListener('openwin2', function(e){
		var win2 = Ti.UI.createWindow({
			backgroundColor: 'red'
		});
		var closeButton = Ti.UI.createButton({
			title: 'close',
			height: 50,
			width: 200
		});
		closeButton.addEventListener('click', function(e){
			win2.close();
		})
		win2.add(closeButton);
		tab1.open(win2);
});
var win1 = Ti.UI.currentWindow;

win1.addEventListener('blur', function(e){
	Ti.API.info('blur');
});
win1.addEventListener('focus', function(e){
	Ti.API.info('focus');
});
var openButton = Ti.UI.createButton({
	title:'open',
	height: 50,
	width: 200
});
win1.add(openButton);

openButton.addEventListener('click', function(e){
	Ti.App.fireEvent('openwin2');
});

Associated Helpdesk Ticket

http://appc.me/c/APP-141651

Comments

  1. Bill Dawson 2011-08-10

    Pull request ready https://github.com/appcelerator/titanium_mobile/pull/357
  2. Don Thorp 2011-08-29

    Review and merge.
  3. Alan Vaghti 2011-09-08

    Closing. Passed as expected on HTC Hero 2.1update1, Nexus S 2.3.4, LG-V909 (GSlate) 3.1. SDK: version=1.8.0 timestamp=09/06/11 15:53 githash=bc5c585...
  4. Don Thorp 2011-11-05

    Standardizing summary and labels.

JSON Source