【问题标题】:how to enalbe "Press ESC to exit full screen mode" in electron如何在电子中启用“按ESC退出全屏模式”
【发布时间】:2020-03-03 00:19:27
【问题描述】:

当我在 iframe 中全屏显示时,如何在 electron 中启用“按 ESC 退出全屏模式消息”?

观察:在 Chrome 中具有相同选项的相同 iframe 会显示消息,但 electron 不会。

【问题讨论】:

    标签: google-chrome iframe electron chromium


    【解决方案1】:

    最简单的方法是使用remote 模块进行一些简单的窗口控制。

    const remote = require("electron").remote;
    
    document.addEventListener("keydown", event => {
        switch (event.key) {
            case "Escape":
                if (remote.getCurrentWindow().isFullScreen()) {
                    remote.getCurrentWindow().setFullScreen(false);
                }
                break;
             }
    });
    

    代码和原始答案hereZen

    【讨论】:

    • 我的问题是,如何在电子中启用消息。不是如何退出全屏模式。
    • 啊,在那种情况下,你不能(至少不是本机)。该消息是特定于 Chrome 的,您必须自己创建这样的消息。为此,您需要检测 enter-html-full-screen 事件何时触发,并在触发时显示您自己的消息。
    猜你喜欢
    • 2014-10-21
    • 2019-07-23
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-27
    • 2015-03-15
    • 2021-02-18
    相关资源
    最近更新 更多