を示していない、と私は唯一のネイティブメニューは、内部の通常の容疑者で、「編集」メニューであることを示したいと思います。ネイティブメニューは、私は電子アプリを作成するために、電子クイックスタートを使用OS X電子
はしかし、検索と「機能していない電子メニュー」のすべての関連性の高いGoogleの結果を排出した後、私は途方に暮れてよ。
私の現在のmain.jsファイル:
const {app, Menu, BrowserWindow} = require('electron')
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
app.setName('mathulator');
function createWindow() {
// Create the browser window.
mainWindow = new BrowserWindow({width: 900, height: 550})
// and load the index.html of the app.
mainWindow.loadURL(`file://${__dirname}/index.html`)
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
const template = [
{
label: 'Mathulator',
submenu: [
{
role: 'quit'
}
]
},
{
label: 'Edit',
submenu: [
{
role: 'undo'
},
{
role: 'redo'
},
{
type: 'separator'
},
{
role: 'cut'
},
{
role: 'copy'
},
{
role: 'paste'
},
{
role: 'pasteandmatchstyle'
},
{
role: 'delete'
},
{
role: 'selectall'
}
]
}
]
mainWindow.setMenu(Menu.buildFromTemplate(template))
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
})
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)
// Quit when all windows are closed.
app.on('window-all-closed', function() {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function() {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow()
}
})
は私も無駄に、電子パッケージャでそれをパッケージ化しました。
私はmain.jsファイルで実行しています。メインファイルはmain.jsファイルで実行されていますが、Web上の曖昧な情報や畳み込まれた情報から得られるものはメインプロセスなので、メニューを作成する必要があります。
私はrender.jsでそれをやってみましたが、私はこれを示唆しています。無駄に。デフォルトの電子クイックスタートメニュー、または「Quit」というラベルの付いた項目の入った簡単なメニューが表示されます。私が間違って何を
をやっているかもしれない、と私は入手可能な情報から何を誤解しているのでしょうか?
編集:私は実際にそうように、Menu.setApplicationMenu()
初めて使ってみました、間違ったファイルを添付:ここ
const {app, Menu, BrowserWindow} = require('electron')
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
app.setName('mathulator');
function createWindow() {
// Create the browser window.
mainWindow = new BrowserWindow({width: 900, height: 550});
// and load the index.html of the app.
mainWindow.loadURL(`file://${__dirname}/index.html`);
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);
// Quit when all windows are closed.
app.on('window-all-closed', function() {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
})
app.on('activate', function() {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
})
const template = [
{
label: 'Mathulator',
submenu: [
{
role: 'quit'
}
]
},
{
label: 'Edit',
submenu: [
{
role: 'undo'
},
{
role: 'redo'
},
{
type: 'separator'
},
{
role: 'cut'
},
{
role: 'copy'
},
{
role: 'paste'
},
{
role: 'pasteandmatchstyle'
},
{
role: 'delete'
},
{
role: 'selectall'
}
]
}
];
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
編集を参照してください。それはもともと、まだアプリのメニューを試してみました。 – thephpdev
@thephpdevアプリケーションの準備ができたら 'Menu.setApplicationMenu()'を呼び出す必要があります。そのため、その呼び出しを 'createWindow()'に移動してください。 –
私は参照してください。私はちょっと厚く感じましたが、私はそれを試みたと思っていましたが、今私は 'mainWindow.setMenu()'と呼んでいます。私は電子を初めて使った人です。興味がある場合に備えて、これは私の最初の電子アプリです。 https://github.com/CaelanStewart/Mathulator – thephpdev