Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-8628

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

    Details

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

        Attachments

          Activity

            People

            • Assignee:
              vduggal Vishal Duggal (Inactive)
              Reporter:
              bitshftr Shawn Lipscomb
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-12943
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Integration