Handling Dom Events


#1

Been looking around the documentation for a while and can’t seem to figure out how to handle DOM events within Electron. At this point, I’m just trying to add a click event to a button that closes the window. If someone could steer me in the right direction it’d be much appreciated!


#2

Okay, I think I figured it out a bit. I had a code error which was breaking my test code (changing CSS). I got the window to close by adding an event listener to the button that when called passes ipc.send('close-window'); which then responds with
ipc.on('close-window', function(event) { mainWindow.close(); });

Not sure this is the correct way to go about this, but it works.