Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8628] iOS: focus event doesn't fire when AlertDialog click event opens new window using NavigationGroup, and then you go "back"

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-07-10T03:07:02.000+0000
Affected Version/sn/a
Fix Version/sRelease 2.0.2, Release 2.1.0, Sprint 2012-09 API
ComponentsiOS
LabelsSupportTeam, api, module_navgroup, qe-testadded, titanbeta
ReporterShawn Lipscomb
AssigneeVishal Duggal
Created2012-04-09T12:25:44.000+0000
Updated2012-07-10T15:57:13.000+0000

Description

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);

Comments

  1. Shawn Lipscomb 2012-04-20

    HD ticket: http://support.appcelerator.com/tickets/APP-277754
  2. Shawn Lipscomb 2012-04-20

    Also a problem in SDK 2.1.0.v20120416160358.
  3. Stephen Tramer 2012-04-26

    Moving out of core.
  4. Vishal Duggal 2012-04-27

    Same root issue as the one reported in TIMOB-8559
  5. Vishal Duggal 2012-04-27

    Pull pending https://github.com/appcelerator/titanium_mobile/pull/2090
  6. Natalie Huynh 2012-05-10

    Tested with 2.0.2.v20120505151714 on iphone 4 4.3.5 and simulator 4.3
  7. Shawn Lipscomb 2012-07-03

    Verified fixed in SDK 2.1.0.GA.
  8. Anshu Mittal 2012-07-10

    Reopening to update labels.

JSON Source