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

iOS: Window focus and blur events no longer fire after hiding a window

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: iOS
    • Environment:

      Titanium SDK 3.2.0.GA, iOS 7

      Description

      Create a window which has focus and blur events. These events fire correctly when you open and close a new window over top. However, if you open a new window over top and then hide that new window, the window below no longer fires focus and blur events, nor do any other windows that are opened and closed.

      Consider the following code below that reproduces the issue. As you open and close win1, the focus and blur events of baseWindow fire correctly. However after you open window 2 and then hide it, no more focus and blur events are fired for baseWindow. You could also add focus and blur events to win1, and these wouldn't fire after hiding win2 either.

      var baseWindow = Ti.UI.createWindow({ backgroundColor: 'blue', title: 'Base Window' });
      baseWindow.addEventListener('focus', function() {
          alert('baseWindow was focused');
      });
      baseWindow.addEventListener('blur', function() {
          alert('baseWindow was blurred');
      });
       
      var openWin1Button = Ti.UI.createButton({
          top: 20, title: 'Open window 1'
      });
      openWin1Button.addEventListener('click', function() {
          var win1 = Ti.UI.createWindow({ backgroundColor: 'green', title: 'Window 1' });
       
          var closeWin1Button = Ti.UI.createButton({
              top: 20, title: 'Close window 1'
          });
          closeWin1Button.addEventListener('click', function() {
              win1.close();
          });
          win1.add(closeWin1Button);
       
          win1.open();
       
      });
      baseWindow.add(openWin1Button);
       
      var win2;
      var openWin2Button = Ti.UI.createButton({
          top: 80, title: 'Open window 2'
      });
      openWin2Button.addEventListener('click', function() {
          if(!win2) {
              win2 = Ti.UI.createWindow({ backgroundColor: 'red', title: 'Window 2' });
       
              var closeWin2Button = Ti.UI.createButton({
                  top: 20, title: 'Hide window 2'
              });
              closeWin2Button.addEventListener('click', function() {
                  win2.hide();
              });
              win2.add(closeWin2Button);
       
              win2.open();
          }
          else {
              win2.show();
          }
       
      });
      baseWindow.add(openWin2Button);
       
      baseWindow.open();
      

      This worked fine with Titanium SDK 3.1.x and iOS 6 but no longer does. I also tried setting the opacity and height of win2 to 0 but it had no affect. As long as win2 is open (but hidden), the focus and blur events of other windows will not fire.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jtoth Justin Toth
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Backbone Issue Sync

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

                  Git Integration