question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: is there a way to disable auto focus of electron app after "npm run dev"

See original GitHub issue

Hello, I’ve got tired of getting constantly switched to electron app window after I run npm run dev or make some changes in source code. Is there some way to disable this behaviour?

System

  • Node version: 8.1.0
  • NPM version: 5.0.3
  • vue-cli version: 2.8.2
  • Operating System: Mac OS 10.12.5

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
SimulatedGREGcommented, Jun 14, 2017

@imomaliev

You can simply change the BrowserWindow API used to mainWindow.showInactive() and set show to false in the constructor options.

https://electron.atom.io/docs/api/browser-window/#winshowinactive

src/main/index.js

mainWindow = new BrowserWindow({
  height: 563,
  useContentSize: true,
  width: 1000,

  // disable initial window from showing
  show: false
})

// load page with url
mainWindow.loadURL(winURL)

// show window without setting focus
mainWindow.showInactive()

Hope this helps.

0reactions
Mehdi-Hpcommented, Apr 9, 2020

@SimulatedGREG what if we want to make the window visible but don’t want the window to grab focus ?

Actually with showInactive() it does get visible and does not grab the focus.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Disable reload via keyboard shortcut electron app
This seems to be still an issue. There's no way to catch the CMD+R (or CTRL+R or F5) shortcut even in bundled app...
Read more >
app | Electron
If the user pressed Cmd + Q , or the developer called app.quit() , Electron will first try to close all the windows...
Read more >
How to Setup Simple Hot-Reload on an Electron App With No ...
Now, if you run your Electron app ( npm start ) and open the developer tools window in your app (click View ->...
Read more >
Build an Electron App in Under 60 Minutes - YouTube
In this video we will build a desktop application using Electron. js which allows us to build desktop apps using only JavaScript.
Read more >
How to build an Electron app using create-react-app ... - Medium
create-react-app makes certain assumptions about a typical React setup. If these assumptions aren't for you, there is an option to eject an application...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found