Monday 23 January 2017

Managing multiple windows with node+electron?

Hey guys, I've been struggling for hours to do this and it's beyond driving me crazy at this point. I'm a node newbie, found electron, and thought a cool way to work on my JS skills in general would be to make an app my gf has always wanted, something similar to the macOS stickies app but in windows. However, I've had a hell of a time wrapping me head around how to make this work in electron, as the only "main" portion of the app should be the top menu bar - there is no actual main windows, just as many stickies as the user decides to add.I did find this module which supposedly makes managing multiple windows easier, but it has led me to nothing but horus of frustration. I cannot even get the simplest main process implementation working. I have two current problems: I can only get the template to show up if I make it the defaultLayout, and no matter what I cannot get the content of the page I'm trying to load into the template's . It doesn't even make sense to me how this module pulls in files or browsers the directory structure at all.Here's my directory structure:app/ css/ img/ js/ layouts/ notecard.html index.html menu.html node_modules/ main.js package.json And my main.js code:// Requires var electron = require('electron'); var app = electron.app; var BrowserWindow = electron.BrowserWindow; var windowManager = require('electron-window-manager'); var mainWindow = null; function createWindow() { windowManager.init({ 'layouts': { 'default': '/app/layouts/notecard.html' } // 'defaultLayout': 'default' }); windowManager.open('index', 'Welcome to this thing hopefully','/app/index.html'); } When I comment out the default layout line, nothing works. When I include it, the layout actually gets loaded (code below):

TESTING TESTING
Hello, may I have a word? Have you every heard about TESTING?

TESTING TESTING
Hello, may I have a word? Have you every heard about TESTING?

No matter what I do, it just displays on the page, and does not pull in any content. Why is this so hard? The documentation makes it seem so easy. What am I doing wrong here to where I basically cannot get anything to work?

Submitted January 24, 2017 at 04:53AM by tangled_up_in_blue

No comments:

Post a Comment