上一个窗口焦点/电子 [英] Previous Window Focus / Electron

查看:57
本文介绍了上一个窗口焦点/电子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我的头很难抓.我只是从电子开始,到目前为止一切都很好.但是,当窗口被隐藏时(这是一个显示快捷方式的弹出窗口,当您按Enter键时该窗口将消失),我想将焦点移回到上一个窗口.

Currently scratching my head on a tough one. I'm just starting with electron and so far so good. However, when the window gets hidden (it's a popup showing with a shortcut, that goes away when you press enter), I'd like to give the focus back to the previous window.

我使用的是Mac,菜单栏显示了我以前的应用程序的名称,因此看起来焦点集中在了该应用程序上,但由于未选择窗口,所以看起来并不是全部.

I'm using Mac, and the menu bar shows my previous app's name so it looks like the focus is given back to the app, but not entirely since the window is not selected.

有什么解决办法吗?

谢谢!

推荐答案

对于Linux:我发现 browserWindow.hide()正确地恢复了焦点.

For Linux: I found browserWindow.hide() correctly restores focus.

对于Windows: browserWindow.minimize()正确地恢复焦点.

For Windows: browserWindow.minimize() correctly restores focus.

对于Mac:我听说(没有Mac要测试)发送菜单命令'hide:'可能有效.

For Mac: I've heard (don't have a mac to test) sending the menu command 'hide:' may work.

这在Linux和Windows上均适用:

This works both on Linux and Windows:

hide() {
    this.window.minimize();
    this.window.hide();
}

show() {
    this.window.show();
    this.window.restore();
}

这篇关于上一个窗口焦点/电子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆