TiSocial.Framework icon indicating copy to clipboard operation
TiSocial.Framework copied to clipboard

Windows loose "focus" event when activity view is loaded.

Open bcpi opened this issue 10 years ago • 9 comments

This is a sample app that shows how the focus event is lost on all windows within a TabGroup right after an activity view is loaded.

My environment is TiSocial.Framework v1.7.3, Ti SDK 3.2.2GA, iOS Simulator 7.1, iPhone 5s iOS 7.1.

Test: Load the sample app. Click between tab 1 and tab 2 several times to see the label change with the focus event. Then click the "share" button to load the activity view. Click cancel on the activity view, and switch tabs back and forth again. Now the focus event does not fire and the labels don't get updated.

app.js

(function() {

    Ti.UI.setBackgroundColor('#ffffff');

    var tg = Ti.UI.createTabGroup(),

        win1 = Ti.UI.createWindow({
            title: 'Tab 1'
        }),

        win2 = Ti.UI.createWindow({
            title: 'Tab 2'
        }),

        tab1 = Ti.UI.createTab({
            title: 'Tab 1',
            window: win1
        }),

        tab2 = Ti.UI.createTab({
            title: 'Tab 2',
            window: win2
        }),

        btn = Ti.UI.createButton({top: 80, title:'Click to Share'}),

        lbl1 = Ti.UI.createLabel({font: {fontSize:40}}),

        lbl2 = Ti.UI.createLabel({font: {fontSize:40}}),

        social = require('dk.napp.social'),

        idx1 = 0,

        idx2 = 100;


    // events
    btn.addEventListener('click', function() {
        social.activityView({
             text: 'Testing...'
        });
    });

    win1.addEventListener('focus', function(e) {
        idx1++;
        lbl1.text = 'Tab 1: ' + idx1;
        Ti.API.info('Focused tab 1 window.');
    });

    win2.addEventListener('focus', function(e) {
        idx2--;
        lbl2.text = 'Tab 2: ' + idx2;
        Ti.API.info('Focused tab 2 window.');
    });


    // assemble + open
    win1.add(btn);
    win1.add(lbl1);
    win2.add(lbl2);
    tg.addTab(tab1);
    tg.addTab(tab2);
    tg.open();

})();

bcpi avatar Apr 17 '14 17:04 bcpi