久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

是否有顯示和隱藏 Electron 應用程序的事件?

Are there events for when an Electron app is shown and hidden?(是否有顯示和隱藏 Electron 應用程序的事件?)
本文介紹了是否有顯示和隱藏 Electron 應用程序的事件?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我一直在尋找當 應用程序 顯示或隱藏時的 Electron app 事件.我在文檔中看到有 'browser-window-blur' 和 'browser-window-focus' 但是那些不做我想做的事.

I have been looking for Electron app events for when the application is shown or hidden. I see in the docs that there is 'browser-window-blur' and 'browser-window-focus' but those do not do what I want.

我想知道用戶何時切換到另一個應用程序或切換回我的應用程序.如果用戶在瀏覽器窗口(包括開發者工具"窗口)之間切換,則會觸發上述事件.

I would like to know when the user has switched to another application or switched back to my app. The above events get triggered if the user switches between browser windows –?including the "developer's tools" window.

main.js中的代碼

app.on('browser-window-focus', () => {
    if (mainWindow) {
        console.log('browser-window-focus');

        mainWindow.webContents.send('projectMsg', { "event": "focus" });
    }
});

app.on('browser-window-blur', () => {
    console.log('browser-window-blur');
    if (mainWindow) {
        mainWindow.webContents.send('projectMsg', { "event": "blur" });
    }
});

推薦答案

在我看來和你描述的完全一樣,所以可能要求不同.

It seems to me that it works exactly as you described, so maybe the requirements are different.

此代碼

const {app, BrowserWindow} = require('electron')

app.on('browser-window-focus', (event, win) => {
  console.log('browser-window-focus', win.webContents.id)
})
app.on('browser-window-blur', (event, win) => {
  if (win.webContents.isDevToolsFocused()) {
    console.log('Ignore this case')
  } else {
    console.log('browser-window-blur', win.webContents.id)
  }
})
app.once('ready', () => {
  new BrowserWindow()
  new BrowserWindow().webContents.openDevTools({detach: true})
})

考慮到最初沒有重點關注,以下列方式工作(在 3.0.3 中):

works the following way (in 3.0.3) given that nothing is focused initially:

  • 點擊窗口 1 打印 browser-window-focus 1
  • 點擊窗口 2 打印 browser-window-blur 1 browser-window-focus 2
  • 點擊devtools窗口打印browser-window-blur 2 忽略這種情況
  • Clicking on window 1 prints browser-window-focus 1
  • Clicking on window 2 prints browser-window-blur 1 browser-window-focus 2
  • Clicking on devtools window prints browser-window-blur 2 Ignore this case

據我所知,這些事件中不包含 devtool,對于任何其他聚焦的窗口(包括 devtool),窗口會變得模糊

So as far as I see devtool is not included in these events, windows are getting blurred for any other window focused (including devtool)

這篇關于是否有顯示和隱藏 Electron 應用程序的事件?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 国产1区2区在线观看 | 亚洲品质自拍视频网站 | 精品一二区 | 午夜播放器在线观看 | 欧美精品成人一区二区三区四区 | 91视频亚洲 | 在线看免费 | 日韩精品在线免费 | 国产精品久久欧美久久一区 | 中文字幕亚洲区一区二 | 激情婷婷 | 久久99久久98精品免观看软件 | 欧美精品一区久久 | 亚洲精品一区二区三区蜜桃久 | www.亚洲视频.com | 亚洲精品无人区 | 在线国产中文字幕 | 台湾a级理论片在线观看 | 国产日韩欧美一区二区 | 国产成人精品久久二区二区91 | 青青久久久 | 欧美成年人视频在线观看 | 久久国产精品一区二区三区 | 中文字幕在线一区二区三区 | 九九久久免费视频 | 久久极品 | 国产精品久久久久久久久免费丝袜 | 成人午夜免费在线视频 | 久久www免费人成看片高清 | 久久网一区二区 | h视频在线观看免费 | 91久久| 亚洲精品一区国产精品 | 日韩淫片免费看 | 国产一级影片 | 黄色a三级| 日韩午夜影院 | 精品久久久久久久久久久久久久久久久 | 久久久妇女国产精品影视 | 日本又色又爽又黄又高潮 | 亚洲一区久久 |