GitHub Issue | n/a |
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-09-07T15:43:12.000+0000 |
Affected Version/s | Release 2.0.2, Release 2.1.2, Release 3.0.0 |
Fix Version/s | Release 2.1.3, Release 3.0.0, Sprint 2012-18 API |
Components | Android |
Labels | SupportTeam, api, module_window, qe-testadded |
Reporter | Federico Casali |
Assignee | Vishal Duggal |
Created | 2012-09-06T20:47:34.000+0000 |
Updated | 2013-06-10T23:25:36.000+0000 |
Problem description
Creating a lightweight windows between two heavyweight windows might prevent heavyweight focus event to be fired
Steps to reproduce and sample code
Run the sample code (also on
https://gist.github.com/61044bd87f85742e3b19):
/**
* Creates a simple black light weight window
*/
function LightWeightWindow(){
var win = Ti.UI.createWindow({
backgroundColor: 'black',
});
return win;
}
/**
* Creates a heavy weight window
* @param {Number} num the window number
*/
function HeavyWeightWindow(num){
num ++;
// create the window
var win = Ti.UI.createWindow({
fullscreen: false, // make it heavy weight
backgroundColor: '#ccc',
title: 'win '+num
});
// let's do some processing
for(var i = 0; i < 200; i++) {
win.add(Ti.UI.createView({width:0,height:0,left:0,top:0}));
}
// open next window
var btn = Ti.UI.createButton({
title: 'open win ' + (num + 1)
});
btn.addEventListener('click', function(){
// open light weight window
var lightWeight = LightWeightWindow();
lightWeight.open();
// create the next heavy weight window
var next = HeavyWeightWindow(num);
// open the heavy weight window
next.open();
// lastly, close the light weight window
lightWeight.close();
});
// on focus, show the toast notification
win.addEventListener('focus', function(){
Ti.UI.createNotification({
message:'focus on win '+ num,
duration: Ti.UI.NOTIFICATION_DURATION_SHORT
}).show();
Ti.API.info('focus on win '+ num)
});
win.add(btn);
return win;
}
HeavyWeightWindow(0).open();
Steps to reproduce
- Click on the button to open a lightweight window, create next heavyweight window, open it and then close the lightweight window previously opened.
- On window focus, we show a toast notification
- Open a few windows, then press the back button.
Result: 'focus' event listener is no longer triggered when pressing the back button
Here's another test case, similar to the one above, but has "blur" eventListener added as well.
PR for master https://github.com/appcelerator/titanium_mobile/pull/2888
PR for 2_1_X https://github.com/appcelerator/titanium_mobile/pull/2890
Environment used for verification - Titanium SDK: 2.2.0.v20120907162025 Titanium Studio: 2.1.3.201209071738 Device:Samsung GALAXY Note (2.3.6) Machine OS - MAC 10.8