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

是否有顯示和隱藏 Electron 應(yīng)用程序的事件?

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

問(wèn)題描述

我一直在尋找當(dāng) 應(yīng)用程序 顯示或隱藏時(shí)的 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.

我想知道用戶何時(shí)切換到另一個(gè)應(yīng)用程序或切換回我的應(yīng)用程序.如果用戶在瀏覽器窗口(包括開(kāi)發(fā)者工具"窗口)之間切換,則會(huì)觸發(fā)上述事件.

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" });
    }
});

推薦答案

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

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})
})

考慮到最初沒(méi)有重點(diǎn)關(guān)注,以下列方式工作(在 3.0.3 中):

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

  • 點(diǎn)擊窗口 1 打印 browser-window-focus 1
  • 點(diǎn)擊窗口 2 打印 browser-window-blur 1 browser-window-focus 2
  • 點(diǎn)擊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

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

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

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

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

相關(guān)文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進(jìn)程中創(chuàng)建子窗口時(shí)如何修復(fù) BrowserWindow 不是構(gòu)造函數(shù)錯(cuò)誤) - IT屋-程序員軟件開(kāi)發(fā)技術(shù)
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應(yīng)用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無(wú)法在第二個(gè) loadURL 上執(zhí)行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內(nèi)使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲(chǔ)?)
How to access camera/webcamera inside electron app?(如何在電子應(yīng)用程序中訪問(wèn)相機(jī)/網(wǎng)絡(luò)攝像頭?)
主站蜘蛛池模板: 欧美涩| 亚洲精品视频在线看 | 中文字幕高清av | 欧美一区二区三区在线 | 成年免费大片黄在线观看一级 | 欧美成人在线影院 | 看片地址| 国产成人精品综合 | 亚洲欧美中文日韩在线v日本 | 毛片黄片免费看 | 国产在线精品一区二区三区 | 日本免费一区二区三区视频 | 中文字幕在线观看一区 | 欧美亚洲国产一区 | 国产精品一区二区av | 黑人巨大精品欧美一区二区免费 | 日本在线小视频 | 亚洲网站在线播放 | 天天操天天操 | 亚洲精品一区二区 | 欧美视频区 | 一级片视频免费观看 | 精品国产一区二区国模嫣然 | 久久久久一区二区 | 中文字幕视频在线 | 在线国产视频 | 欧美日韩综合一区 | 亚洲三区视频 | 西西裸体做爰视频 | 久久精品一级 | 激情av网站 | 亚洲毛片在线 | 成年女人免费v片 | 三级成人片| 国产激情亚洲 | aacc678成免费人电影网站 | 国产欧美一级 | 国产激情片在线观看 | 亚洲精品乱码久久久久久9色 | 国产精品777一区二区 | 国产在线h|