Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16208] iOS: Window focus and blur events no longer fire after hiding a window

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labels3.2.0GA, blur, focus, hide, ios, ios7, window
ReporterJustin Toth
AssigneeUnknown
Created2014-01-15T21:31:07.000+0000
Updated2018-02-28T20:03:57.000+0000

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.

Comments

  1. Justin Toth 2014-01-16

    It seems that the focus and blur events not firing are only part of the problem with hidden windows. If you hide a window and then open a new window with a different status bar color (Ti.UI.iPhone.StatusBar.DEFAULT -> Ti.UI.iPhone.StatusBar.LIGHT_CONTENT), the status bar won't update to the new style. It must think the hidden window is still showing so doesn't respect focus/blur/status bar styles on the truly visible window or new windows that open later on.
  2. Felipe Mathies 2014-03-07

  3. Unknown 2014-04-21

    This issue was previously scheduled to be worked on in more than one sprint: * 'Release 3.1.2' (on board '3.1.X Triage') * 'Release 3.0.1/TS 3.0.2' (on board '3.1.0 Triage') * 'Triage' (on board '3.2.X Triage') Starting from JIRA Agile 6.3, an issue can only belong to a single future sprint. Read more about this change: http://docs.atlassian.com/agile/docs-0630/Sprint+Marker+Migration This issue is now scheduled for future sprint 'Release 3.1.2' (on board '3.1.X Triage'). If this is incorrect, please update the issue accordingly. This comment was automatically generated by JIRA. If it is no longer relevant, please feel free to delete it.
  4. Shameer Jan 2014-09-11

    This issue reproduces with TiSDK 3.2.0 and 3.4.0 GA iOS 7.1 iOS 7.0 TiSDK 3.4.0 ,3.2.0 Appcelerator Studio, build: 3.3.0.201407111535 Titanium Command-Line Interface, CLI version 3.3.0,

JSON Source