本文整理汇总了TypeScript中menu.setApplicationMenu函数的典型用法代码示例。如果您正苦于以下问题:TypeScript setApplicationMenu函数的具体用法?TypeScript setApplicationMenu怎么用?TypeScript setApplicationMenu使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setApplicationMenu函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: BuildMenu
private BuildMenu(): void {
var template: any = [
{
label: app.getName(),
submenu: [
{
label: "Save",
accelerator: "Command+S",
click: (): void => { this.mainWindow.webContents.send("save"); }
},
{ type: "separator" },
{
label: "Quit",
accelerator: "Command+Q",
click: (): void => { app.quit(); }
},
]
},
{
label: "Edit",
submenu: [
{
label: "Update",
accelerator: "Command+U",
click: (): void => { this.mainWindow.webContents.send("update"); }
},
{
label: "Copy to clipboard",
click: (): void => { this.mainWindow.webContents.send("requestClipboardArea"); }
},
]
},
{
label: "Help",
submenu: [
{
label: "Versions",
click: (): void => aboutInfo.AboutInfo.DisplayExtra(this.mainWindow)
}
]
}];
var menu: any = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
}
示例2: setMenu
//.........这里部分代码省略.........
}
},
{
label: 'Toggle Developer Tools',
accelerator: (function() {
if (process.platform == 'darwin')
return 'Alt+Command+I';
else
return 'Ctrl+Shift+I';
})(),
click: function(_: any, focusedWindow: GitHubElectron.BrowserWindow) {
if (focusedWindow)
focusedWindow.toggleDevTools();
}
},
]
},
{
label: 'Window',
role: 'window',
submenu: [
{
label: 'Minimize',
accelerator: 'CmdOrCtrl+M',
role: 'minimize'
},
{
label: 'Close',
accelerator: 'CmdOrCtrl+W',
role: 'close'
},
{
type: 'separator'
},
{
label: 'Bring All to Front',
role: 'front'
}
]
},
{
label: 'Help',
role: 'help',
submenu: [
{
label: 'Repository',
click: function() { openExternal('http://github.com/rhysd/Tilectron') }
},
]
},
] as GitHubElectron.MenuItemOptions[];
if (process.platform == 'darwin') {
template.unshift({
label: 'Tilectron',
submenu: [
{
label: 'About Tilectron',
role: 'about'
},
{
type: 'separator'
},
{
label: 'Services',
role: 'services',
submenu: []
},
{
type: 'separator'
},
{
label: 'Hide Tilectron',
accelerator: 'Command+H',
role: 'hide'
},
{
label: 'Hide Others',
accelerator: 'Command+Shift+H',
role: 'hideothers:'
},
{
label: 'Show All',
role: 'unhide:'
},
{
type: 'separator'
},
{
label: 'Quit',
accelerator: 'Command+Q',
click: function() { app.quit(); }
},
]
} as GitHubElectron.MenuItemOptions);
}
let menu = buildFromTemplate(template);
setApplicationMenu(menu);
}
示例3: BrowserWindow
//.........这里部分代码省略.........
accelerator: 'Command+A',
selector: 'selectAll:'
}]
}, {
label: 'View',
submenu: (process.env.NODE_ENV === 'development') ? [{
label: 'Reload',
accelerator: 'Command+R',
click:() => {
mainWindow.restart();
}
}, {
label: 'Toggle Full Screen',
accelerator: 'Ctrl+Command+F',
click:() => {
mainWindow.setFullScreen(!mainWindow.isFullScreen());
}
}, {
label: 'Toggle Developer Tools',
accelerator: 'Alt+Command+I',
click:() => {
mainWindow.toggleDevTools();
}
}] : [{
label: 'Toggle Full Screen',
accelerator: 'Ctrl+Command+F',
click:() => {
mainWindow.setFullScreen(!mainWindow.isFullScreen());
}
}]
}, {
label: 'Window',
submenu: [{
label: 'Minimize',
accelerator: 'Command+M',
selector: 'performMiniaturize:'
}, {
label: 'Close',
accelerator: 'Command+W',
selector: 'performClose:'
}, {
type: 'separator'
}, {
label: 'Bring All to Front',
selector: 'arrangeInFront:'
}]
},
langMenu,
helpMenu];
menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
} else {
template = [{
label: '&File',
submenu: [{
label: '&Open',
accelerator: 'Ctrl+O'
}, {
label: '&Close',
accelerator: 'Ctrl+W',
click:() => {
mainWindow.close();
}
}]
}, {
label: '&View',
submenu: (process.env.NODE_ENV === 'development') ? [{
label: '&Reload',
accelerator: 'Ctrl+R',
click:() => {
mainWindow.restart();
}
}, {
label: 'Toggle &Full Screen',
accelerator: 'F11',
click:() => {
mainWindow.setFullScreen(!mainWindow.isFullScreen());
}
}, {
label: 'Toggle &Developer Tools',
accelerator: 'Alt+Ctrl+I',
click:() => {
mainWindow.toggleDevTools();
}
}] : [{
label: 'Toggle &Full Screen',
accelerator: 'F11',
click:() => {
mainWindow.setFullScreen(!mainWindow.isFullScreen());
}
}]
},
langMenu,
helpMenu];
menu = Menu.buildFromTemplate(template);
mainWindow.setMenu(menu);
}
});
示例4: function
//.........这里部分代码省略.........
},
{
label: "Toggle Full Screen",
accelerator: "Ctrl+Command+F",
click: function () {
browserWindow.setFullScreen(!browserWindow.isFullScreen());
},
},
{
label: "Toggle Developer Tools",
accelerator: "Alt+Command+I",
click: function () {
browserWindow.webContents.toggleDevTools();
},
},
],
},
{
label: "Window",
submenu: [
{
label: "Minimize",
accelerator: "Command+M",
selector: "performMiniaturize:",
},
{
label: "Close",
accelerator: "Command+W",
selector: "performClose:",
},
{
type: "separator"
},
{
label: "Bring All to Front",
selector: "arrangeInFront:",
},
],
},
{
label: "Help",
submenu: [
{
label: "GitHub Repository",
click: function () {
/* tslint:disable:no-unused-expression */
require("shell").openExternal("https://github.com/shockone/black-screen");
},
},
],
},
];
let menu = menuConstructor.buildFromTemplate(template);
menuConstructor.setApplicationMenu(menu);
} else {
const template = [
{
label: "&View",
submenu: [
{
label: "&Reload",
accelerator: "Ctrl+R",
click: function () {
browserWindow.reload();
},
},
{
label: "Toggle &Full Screen",
accelerator: "F11",
click: function () {
browserWindow.setFullScreen(!browserWindow.isFullScreen());
},
},
{
label: "Toggle &Developer Tools",
accelerator: "Alt+Ctrl+I",
click: function () {
browserWindow.webContents.toggleDevTools();
},
},
],
},
{
label: "Help",
submenu: [
{
label: "GitHub Repository",
click: function () {
require("shell").openExternal("https://github.com/shockone/black-screen");
},
},
],
},
];
let menu = menuConstructor.buildFromTemplate(template);
browserWindow.setMenu(menu);
}
},
示例5: function
setMenu: (app: Electron.App, browserWindow: Electron.BrowserWindow) => {
if (process.platform === "darwin") {
const template: Electron.MenuItemOptions[] = [
{
label: "Black Screen",
submenu: [
{
label: "About Black Screen",
role: "about",
},
{
label: "Quit",
accelerator: "Command+Q",
click: function () {
app.quit();
},
},
],
},
{
label: "Edit",
submenu: [
{
label: "Undo",
accelerator: "Command+Z",
role: "undo",
},
{
label: "Redo",
accelerator: "Shift+Command+Z",
role: "redo",
},
{
type: "separator",
},
{
label: "Cut",
accelerator: "Command+X",
role: "cut",
},
{
label: "Copy",
accelerator: "Command+C",
role: "copy",
},
{
label: "Paste",
accelerator: "Command+V",
role: "paste",
},
{
label: "Select All",
accelerator: "Command+A",
role: "selectall",
},
],
},
{
label: "View",
submenu: [
{
label: "Reload",
accelerator: "Command+R",
click: function () {
browserWindow.reload();
},
},
{
label: "Toggle Full Screen",
accelerator: "Ctrl+Command+F",
click: function () {
browserWindow.setFullScreen(!browserWindow.isFullScreen());
},
},
{
label: "Toggle Developer Tools",
accelerator: "Alt+Command+I",
click: function () {
browserWindow.webContents.toggleDevTools();
},
},
],
},
{
label: "Help",
submenu: [
{
label: "GitHub Repository",
click: function () {
/* tslint:disable:no-unused-expression */
require("shell").openExternal("https://github.com/shockone/black-screen");
},
},
],
},
];
let menu = menuConstructor.buildFromTemplate(template);
menuConstructor.setApplicationMenu(menu);
} else {
//.........这里部分代码省略.........
示例6: function
//.........这里部分代码省略.........
}
},
{
label: 'Toggle Full Screen',
accelerator: 'Ctrl+Command+F',
click: function () {
browserWindow.setFullScreen(!browserWindow.isFullScreen());
}
},
{
label: 'Toggle Developer Tools',
accelerator: 'Alt+Command+I',
click: function () {
browserWindow.toggleDevTools();
}
}
]
},
{
label: 'Window',
submenu: [
{
label: 'Minimize',
accelerator: 'Command+M',
selector: 'performMiniaturize:'
},
{
label: 'Close',
accelerator: 'Command+W',
selector: 'performClose:'
},
{
type: 'separator'
},
{
label: 'Bring All to Front',
selector: 'arrangeInFront:'
}
]
},
{
label: 'Help',
submenu: [
{
label: 'GitHub Repository',
click: function () {
require('shell').openExternal('https://github.com/shockone/black-screen')
}
}
]
}
];
let menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
} else {
template = [
{
label: '&View',
submenu: [
{
label: '&Reload',
accelerator: 'Ctrl+R',
click: function () {
browserWindow.restart();
}
},
{
label: 'Toggle &Full Screen',
accelerator: 'F11',
click: function () {
browserWindow.setFullScreen(!browserWindow.isFullScreen());
}
},
{
label: 'Toggle &Developer Tools',
accelerator: 'Alt+Ctrl+I',
click: function () {
browserWindow.toggleDevTools();
}
}
]
},
{
label: 'Help',
submenu: [
{
label: 'GitHub Repository',
click: function () {
require('shell').openExternal('https://github.com/shockone/black-screen')
}
}
]
}
];
let menu = Menu.buildFromTemplate(template);
browserWindow.setMenu(menu);
}
}