AlexTorresDev / custom-electron-titlebar

Custom electon title bar inpire on VS Code title bar
MIT License
870 stars 149 forks source link

Menu Items disappear when deploying to windows executables #108

Closed webmastersJS closed 2 years ago

webmastersJS commented 4 years ago

Hello guys... I'm quite new to the custom-electron-titlebar package

I was starting to create my title bar the I created the buttons. Everything was doing fine when I'm using the "electron ." script. But then, I wanted to test my application on the Windows platform so I used an electron packager to deploy to windows executable file. When I opened it, I noticed that the menu buttons are missing. I built the electron app again now with the dev tools opened. I saw that there is an error...

image

I don't know what to do since I'm only a beginner... Here my code...

Javascript Renderer process

`const customTitlebar = require("custom-electron-titlebar"); const remote = require("electron").remote;

const app = remote.app; const dialog = remote.dialog; const shell = remote.shell;

const fs = require('fs');

var titlebar = new customTitlebar.Titlebar({ backgroundColor: customTitlebar.Color.fromHex("#000"), icon: "./vendor/imgs/icon.ico", });

const menu = new remote.Menu(); menu.append( new remote.MenuItem({ label: "File", submenu: [{ label: "New Project", click: () => { window.location.replace("index.html"); }, }, { label: "Open Project", click: () => { openProject('desktop'); } }, ], }) );`

`menu.append( new remote.MenuItem({ label: "Item 2", submenu: [{ label: "Subitem checkbox", type: "checkbox", checked: true, }, { type: "separator", }, { label: "Subitem with submenu", submenu: [{ label: "Submenu &item 1", accelerator: "Ctrl+T", }, ], }, ], }) );

titlebar.updateMenu(menu);

titlebar.updateTitle("Game LaunchPad | New Project");

function openProject(defaultPath) { var dPath = app.getPath(defaultPath); var openDiag = dialog.showOpenDialog({ properties: ["openFile", "multiSelections"], defaultPath: dPath, filters: [{

        name: "GameLPad Project",
        extensions: ["glp"]

    }]
}, (fileNames) => {
    if (fileNames === undefined) {
        console.log("No file selected");
        return;
    }

    fs.readFile(fileNames[0], 'utf-8', (err, data) => {
        if (err) {
            alert("An error ocurred reading the file :" + err.message);
            return;
        }

        // Change how to handle the file content
        console.log("The file content is : " + data);
    });
});

}`

I hope someone notices this thank you

Kiyozz commented 3 years ago

If you create the menu before the new Titlebar using

const menu = ...

new Titlebar({
  menu: yourMenu,
  backgroundColor: yourColor
})

does that change anything?