Created
September 22, 2023 07:48
-
-
Save Imperat/624d9989cff29005e6f9e8a9cc185eef to your computer and use it in GitHub Desktop.
Cursor Movement Causes Window Blur on App Startup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {app, BrowserView, BrowserWindow} = require('electron') | |
app.whenReady().then(function createWindow () { | |
const mainWindow = new BrowserWindow({ width: 1080, height: 720 }); | |
const browserView = new BrowserView(); | |
browserView.webContents.loadURL('https://electronjs.org') | |
mainWindow.addBrowserView(browserView); | |
browserView.setBounds({ x: 0, y: 0, width: 1080, height: 720 }); | |
// This is the problem: | |
browserView.webContents.focus(); | |
// This fixes it: | |
// setTimeout(() => browserView.webContents.focus()); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "shocking-sound-quit-u8cib", | |
"productName": "shocking-sound-quit-u8cib", | |
"description": "My Electron application description", | |
"keywords": [], | |
"main": "./main.js", | |
"version": "1.0.0", | |
"author": "leliakin", | |
"scripts": { | |
"start": "electron ." | |
}, | |
"dependencies": {}, | |
"devDependencies": { | |
"electron": "25.8.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment