Skip to content
This repository has been archived by the owner on Apr 8, 2021. It is now read-only.

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

Open
bcpi opened this issue Apr 17, 2014 · 9 comments
Open

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

bcpi opened this issue Apr 17, 2014 · 9 comments

Comments

@bcpi
Copy link

bcpi commented Apr 17, 2014

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

})();
@jdrucey
Copy link

jdrucey commented May 1, 2014

^ I second this! My app relies on the 'focus' event, with out a fix, this bug renders my app unusable =(

@Raphzz
Copy link

Raphzz commented Jun 25, 2014

^ Happens on my app as well...all windows looses focus event

@justadaniel
Copy link

Same here

@mobilebanzai
Copy link

Same here, Mads are you listening?

@kopiro
Copy link

kopiro commented Jul 18, 2014

Same here.

@bcpi
Copy link
Author

bcpi commented Jul 30, 2014

also present in Ti SDK 3.0.0GA

@paomosca
Copy link

paomosca commented Oct 1, 2014

i confirm in 3.3.0GA and 3.2.3GA, after closing the activity or after sharing, all the app (every window, even not already created) loose focus event, so apparently there is an overlay win on top of the stack that never release correctly

@paomosca
Copy link

paomosca commented Oct 2, 2014

guys waiting for being fixed as soon as possible try this workaround:

var fakeWin = Ti.UI.createWindow({
backgroundColor: 'transparent',
zIndex: 1500,
touchEnabled: false,
top: 20//fullscreen: true
});
fakeWin.open();
fakeWin.close();

on complete, error and cancelled events

@bradwhiteVB
Copy link

Hi wondering why there has been no movement on this issue since it is such a deal breaker. I'd like to also add that blur events are also removed.

I tried the fake window technique and it doesn't work for iPhon6 and iphone 7 devices on iOS10. For reference I am coding with Ti SDK 5.5.1GA. I also can't work my app unless I use focus events.

Has someone found another workable solution to this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants