Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23366] Windows: Hardware back button exits app instead of closing window inside tab

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionCannot Reproduce
Resolution Date2016-06-02T12:45:06.000+0000
Affected Version/sRelease 5.3.0
Fix Version/sn/a
ComponentsWindows
Labelsn/a
ReporterFokke Zandbergen
AssigneeKota Iguchi
Created2016-05-12T15:32:44.000+0000
Updated2019-05-09T06:46:17.000+0000

Description

Looking at other Windows apps the expected behaviour when using Ti.UI.Tab.open() to open a child Window and then pressing the device back button should close the child Window, revealing the previous Window again. Example for all of this:
var colors = ['blue', 'gray', 'red'];

function createWindow(depth) {

    var win = Ti.UI.createWindow({
        layout: 'vertical',
        backgroundColor: colors[depth % colors.length]
    });

    win.add(Ti.UI.createLabel({
        text: 'Depth ' + depth
    }));

    var openBtn = Ti.UI.createButton({
        top: 20,
        title: 'Open Child'
    });

    openBtn.addEventListener('click', function () {
        tabA.open(createWindow(depth + 1));
    });

    win.add(openBtn);

    if (depth > 0) {
        var closeViaWinBtn = Ti.UI.createButton({
            top: 20,
            title: 'Close via Window'
        });

        closeViaWinBtn.addEventListener('click', function () {
            win.close();
        });

        win.add(closeViaWinBtn);

        var closeViaTabBtn = Ti.UI.createButton({
            top: 20,
            title: 'Close via Tab'
        });

        closeViaTabBtn.addEventListener('click', function () {
            tabA.close(win);
        });

        win.add(closeViaTabBtn);

        var backViaWinButton = Ti.UI.Windows.createAppBarButton({
            icon: Ti.UI.Windows.SystemIcon.BACK
        });

        backViaWinButton.addEventListener('click', function () {
            win.close();
        });

        var backViaTabButton = Ti.UI.Windows.createAppBarButton({
            icon: Ti.UI.Windows.SystemIcon.BACKTOWINDOW
        });

        backViaTabButton.addEventListener('click', function () {
            tabA.close(win);
        });

        win.add(Ti.UI.Windows.createCommandBar({
            items: [backViaWinButton, backViaTabButton]
        }));
    }

    return win;
}

var tabA = Ti.UI.createTab({
    title: 'Tab A',
    window: createWindow(0)
});

var tabB = Ti.UI.createTab({
    title: 'Tab B',
    window: Ti.UI.createWindow({
        backgroundColor: 'green'
    })
});

Ti.UI.createTabGroup({
    tabs: [tabA, tabB]
}).open();

Comments

  1. Kota Iguchi 2016-05-13

    I can't reproduce this on my end with the latest 5_3_X on both WP 8.1 and Windows 10 Mobile.
  2. Fokke Zandbergen 2016-05-31

    This seems to work with latest 5_3_X but I do get this in the logs:
       [WARN]  Window.close: Window is not opened or already closed
       
  3. Kota Iguchi 2016-05-31

    Oops that happens, it should be kept internal. I'll remove it soon. Nice catch!
  4. Kota Iguchi 2016-06-02

    I think we can mark this "Can't Reproduce" for now. Feel free to reopen if that's not the case.

JSON Source