Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable or make inactive Browser Window in Github Electron Atom

I have 2 BrowserWindow(mainWindow,secondaryWindow) instances in my electron application.There is a button in the first window(mainWindow) which when clicked would open the other window(secondaryWindow).

Now my issue is that , I dont want the users to be able to click anything on the mainWindow until the secondaryWindow is closed.

The closest i could get was to use mainWindow.hide().This just completely hides the mainWindow.What i want is for users to still see the mainWindow while the secondaryWindow is active.But while secondaryWindow is active mainWindow should be disabled/inactive.

Any suggestions ???

like image 690
bikash Avatar asked Mar 18 '16 07:03

bikash


People also ask

How do you make an electron window full screen?

To make an Electron app run in full-screen mode when it's started, pass the following configuration option when creating the BrowserWindow instance: mainWindow = new BrowserWindow({fullscreen: true});


1 Answers

You can use the parent/child concept to disable the parent while the child is open:

let top = new BrowserWindow()
let child = new BrowserWindow({parent: top})

You can also extend the concept to full modal windows as follows:

let child = new BrowserWindow({parent: top, modal: true, show: false})
child.loadURL('https://github.com')
child.once('ready-to-show', () => {
  child.show()
})
like image 133
Jens Habegger Avatar answered Oct 05 '22 09:10

Jens Habegger