當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript menu.setApplicationMenu函數代碼示例

本文整理匯總了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);
	}
開發者ID:fforjan,項目名稱:SimpleUML,代碼行數:46,代碼來源:application.ts

示例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);
}
開發者ID:rexfordkelly-on-JS,項目名稱:Tilectron,代碼行數:101,代碼來源:menu.ts

示例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);
  }

});
開發者ID:TheLarkInn,項目名稱:angular2-seed-advanced,代碼行數:101,代碼來源:main.desktop.ts

示例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);
        }
    },
開發者ID:Eugene-msc,項目名稱:black-screen,代碼行數:101,代碼來源:Menu.ts

示例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 {
//.........這裏部分代碼省略.........
開發者ID:bj7,項目名稱:black-screen,代碼行數:101,代碼來源:Menu.ts

示例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);
        }
    }
開發者ID:digideskio,項目名稱:black-screen,代碼行數:101,代碼來源:Menu.ts


注:本文中的menu.setApplicationMenu函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。