Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

focus() works on 'loaded' but fails on 'restore' in recent versions #3042

Closed
gihrig opened this issue Jan 31, 2015 · 2 comments
Closed

focus() works on 'loaded' but fails on 'restore' in recent versions #3042

gihrig opened this issue Jan 31, 2015 · 2 comments
Labels

Comments

@gihrig
Copy link

gihrig commented Jan 31, 2015

Mac OS X 10.10.2
Seems related to #2724
Works as expected in 0.11.3
Works as expected in 0.11.4
Fails in 0.11.5
Fails in 0.11.6
Fails in 0.12.0-alpha2

Not tested on Windows or Linux

The nw.js app registers a global shortcut that shows and hides the app window.

When the nw.js application loads, the window has the focus. A form field, auto-focused in the child html receives key strokes.

Pressing the global shortcut, minimizes the window.
Pressing the global shortcut again restores the window.
If another application window acquires focus while the nw.js app was minimized, the restored nw.js app window does not receive focus.

    // Listen for shortcut's active event.
    shortcut.on('active', function () {
        //toggle application window visibility
        if (isVisible) {
            win.minimize();
        } else {
            win.restore();
        }
    });

    // Open and focus application window with appServer content
    win.window.location = appServer;
    win.on('loaded', function () {
        win.show();
        win.focus(); // <-- Works as expected
        isVisible = true;
    });
    win.on('restore', function () {
        win.focus(); // <-- Does not focus window in 0.11.5+
        isVisible = true;
    });

    win.on('minimize', function () {
        isVisible = false;
    });

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@stale
Copy link

stale bot commented Sep 30, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 30, 2017
@gihrig gihrig closed this as completed Sep 30, 2017
@gihrig
Copy link
Author

gihrig commented Sep 30, 2017

Thanks @stalebot 💯

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

No branches or pull requests

1 participant