Problem Summary
When running a Titanium app in iOS 4.3, the focus event of a window that presents an AlertDialog doesn't fire when returning to that window.
Problem Details
1. Window 1 presents an AlertDialog.
2. Clicking a button on the AlertDialog opens Window 2 via NavigationGroup.
3. When Window 2 is closed via the native Back button, Window 1's focus event does not fire.
Works fine in iOS 5.0
Broken in iOS 4.3
- Works if the second window is not launched from an AlertDialog's click event (for example, if you replaced the AlertDialog with a simple button on the window).
Testcase
1. Put the following code into a new project.
2. Run the app using the iOS 4.3 simulator.
3. Notice that the "main" window's focus event fires.
4. When the AlertDialog comes up, click OK.
5. When the second window appears, click Back.
6. Notice that the "main" window's focus event *does not fire*...this is the problem.
app.js
var win1 = Ti.UI.createWindow({url:'main.js',
navBarHidden:false});
Ti.App.NavGroup = Ti.UI.iPhone.createNavigationGroup({window:win1});
var NavBase = Ti.UI.createWindow();
NavBase.add(Ti.App.NavGroup);
NavBase.open(); // this opens win1 automatically
main.js
MainWin = Ti.UI.currentWindow;
MainWin.addEventListener('focus', OnFocus);
function OnFocus(evt)
{
Ti.API.info('Focus Event fired');
var MessageDialog=Ti.UI.createAlertDialog({
message:'Press OK to open a new window and then press the back button to see me again',
buttonNames:['Ok'],
});
MessageDialog.addEventListener('click',DoClick);
MessageDialog.show();
}
function DoClick(evt)
{
var MainWin = Ti.UI.createWindow({url:'test.js',
layout:'vertical',
navbarHidden: false});
Ti.App.NavGroup.open(MainWin);
}
test.js
TestWin = Ti.UI.currentWindow;
var MyLabel = Ti.UI.createLabel({text: 'Click the back button', color:'white'});
TestWin.add(MyLabel);
HD ticket: http://support.appcelerator.com/tickets/APP-277754
Also a problem in SDK 2.1.0.v20120416160358.
Moving out of core.
Same root issue as the one reported in TIMOB-8559
Pull pending https://github.com/appcelerator/titanium_mobile/pull/2090
Tested with 2.0.2.v20120505151714 on iphone 4 4.3.5 and simulator 4.3
Verified fixed in SDK 2.1.0.GA.
Reopening to update labels.