本文整理汇总了TypeScript中electron.Tray.setContextMenu方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Tray.setContextMenu方法的具体用法?TypeScript Tray.setContextMenu怎么用?TypeScript Tray.setContextMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electron.Tray
的用法示例。
在下文中一共展示了Tray.setContextMenu方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: Tray
app.on("ready", () => {
// window
MainWindow.getInstance().show()
// tray
const tray = new Tray(`${__dirname}/images/icon.png`)
const menu = Menu.buildFromTemplate([
{label: "Setting", click: () => SettingWindow.getInstance().show()},
{label: "Quit", click: () => app.quit()},
])
tray.setToolTip(app.getName())
tray.setContextMenu(menu)
// menu
Menu.setApplicationMenu(Menu.buildFromTemplate([{
label: "Application",
submenu: [
{ label: "About Application", selector: "orderFrontStandardAboutPanel:" },
{ type: "separator" },
{ label: "Quit", accelerator: "Command+Q", click: () => app.quit() },
]}, {
label: "Edit",
submenu: [
{ label: "Undo", accelerator: "CmdOrCtrl+Z", selector: "undo:" },
{ label: "Redo", accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:" },
{ type: "separator" },
{ label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:" },
{ label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" },
{ label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:" },
{ label: "Select All", accelerator: "CmdOrCtrl+A", selector: "selectAll:" },
]},
]))
})
示例2: EstablishTray
function EstablishTray() {
if (tray !== null) {
return
}
/*---------- Tray functions ----------*/
/*---------- Tray functions END ----------*/
let trayIconLocation = ''
if (process.platform === 'darwin') {
trayIconLocation = 'ext_dep/images/TrayTemplate.png'
}
if (process.platform === 'win32') {
trayIconLocation = 'ext_dep/images/WindowsTrayIconAlt3.png'
// trayIconLocation = "ext_dep/images/WindowsTrayIcon.ico"
}
if (process.platform === 'linux') {
trayIconLocation = 'ext_dep/images/LinuxTrayIcon.png'
}
tray = new elc.Tray(path.join(__dirname, trayIconLocation))
tray.setToolTip('Aether')
const contextMenu = elc.Menu.buildFromTemplate(contextMenuTemplate)
tray.setContextMenu(contextMenu)
tray.on('click', () => {
// On windows, the convention is that when an icon in the tray is clicked, it should spawn the app window.
if (process.platform === 'win32') {
openAppWindow()
}
})
}
示例3: createTrayIcon
function createTrayIcon(status: ConnectionStatus) {
const isConnected = status === ConnectionStatus.CONNECTED;
const trayIconImage = isConnected ? trayIconImages.connected : trayIconImages.disconnected;
if (tray) {
tray.setImage(trayIconImage);
} else {
tray = new Tray(trayIconImage);
tray.on('click', () => {
if (!mainWindow) {
createWindow();
return;
}
if (mainWindow.isMinimized() || !mainWindow.isVisible()) {
mainWindow.restore();
mainWindow.show();
mainWindow.focus();
} else {
mainWindow.hide();
}
});
tray.setToolTip('Outline');
}
// Retrieve localized strings, falling back to the pre-populated English default.
const statusString = isConnected ? localizedStrings['connected-server-state'] :
localizedStrings['disconnected-server-state'];
const quitString = localizedStrings['quit'];
const menuTemplate = [
{label: statusString, enabled: false}, {type: 'separator'} as MenuItemConstructorOptions,
{label: quitString, click: quitApp}
];
tray.setContextMenu(Menu.buildFromTemplate(menuTemplate));
}
示例4: function
app.on('ready', function () {
Menu.setApplicationMenu(null);
let iconFile = process.platform === 'win32' ? 'tray.ico' : 'trayTemplate.png';
tray = new Tray(path.normalize(`${app.getAppPath()}/icons/${iconFile}`));
var windowOptions = Object.assign({}, {
width: currentTheme.settings.BTWindowWidth,
height: currentTheme.settings.BTWindowHeight,
webPreferences: { preload: path.resolve(`${__dirname}/preload.js`) }
}, env.windowProperties)
mainWindow = createWindow('main', windowOptions);
mainWindow.loadURL(`file://${currentTheme.path}/${currentTheme.settings.BTMainFile}`);
tray.setContextMenu(trayMenu);
console.log('wtf');
console.log(dialog.showMessageBox(mainWindow, {type: 'info', message: `Welcome Back, You arrived!`}));
if (1 == 1 || env.name === 'development') {
mainWindow.openDevTools();
}
});
示例5: loadFullMenu
.then(kernelSpecs => {
if (Object.keys(kernelSpecs).length !== 0) {
store.dispatch(setKernelSpecs(kernelSpecs));
const menu = loadFullMenu();
Menu.setApplicationMenu(menu);
const logo =
process.platform === "win32" ? "logoWhite" : "logoTemplate";
const trayImage = join(__dirname, "..", "static", `${logo}.png`);
tray = new Tray(trayImage);
const trayMenu = loadTrayMenu();
tray.setContextMenu(trayMenu);
} else {
dialog.showMessageBox(
{
type: "warning",
title: "No Kernels Installed",
buttons: [],
message: "No kernels are installed on your system.",
detail:
"No kernels are installed on your system so you will not be " +
"able to execute code cells in any language. You can read about " +
"installing kernels at " +
"https://ipython.readthedocs.io/en/latest/install/kernel_install.html"
},
index => {
if (index === 0) {
app.quit();
}
}
);
}
})
示例6: function
app.on('ready', function(){
mainWindow = new BrowserWindow({show: false});
mainWindow.loadURL('file://' + __dirname + '/window.html');
appIcon = new Tray(iconPath);
var contextMenu = Menu.buildFromTemplate([
{
label: 'Bilge Adam Bilgilendirme Merkezi',
icon: iconPath
},
{
label: 'Duyuru',
click: function() {
let options: NotificationOptions = {body: "Sistem ayarları güncellemesi başlatılacaktır!"};
createNotification("Bilge Adam Bilgilendirme", options);
}
},
{
label: 'Aç',
click: function() {
mainWindow.show();
}
},
{
label: 'Kapat',
click: function() {
mainWindow.hide();
}
}
]);
appIcon.setToolTip('Bilge Adam Bilgilendirme');
appIcon.setContextMenu(contextMenu);
});
示例7: createWindow
app.on('ready', () => {
tray = new electron.Tray(trayImagePath);
let contextMenu: Electron.Menu = electron.Menu.buildFromTemplate([
{
label: "設定...",
click: () => {
createWindow();
},
},
{
label: "バージョン情報...",
click: () => {
dialog.showMessageBox({
type: "info",
buttons: [ "OK" ],
title: "バージョン情報",
message: "SavannaAlert バージョン 20160910",
});
},
},
{
label: "終了",
click: () => {
app.quit();
},
},
]);
tray.setToolTip("SavannaAlert");
tray.setContextMenu(contextMenu);
tray.on("click", createWindow);
});
示例8: click
create: (win: BrowserWindow) => {
if (is.macos || tray) {
return;
}
const iconPath = path.join(__dirname, '..', 'static', 'IconTray.png');
const toggleWin = (): void => {
if (win.isVisible()) {
win.hide();
} else {
win.show();
}
};
const contextMenu = Menu.buildFromTemplate([
{
label: 'Toggle',
click() {
toggleWin();
}
},
{
type: 'separator'
},
{
role: 'quit'
}
]);
tray = new Tray(iconPath);
tray.setToolTip(`${app.getName()}`);
tray.setContextMenu(contextMenu);
tray.on('click', toggleWin);
},
示例9: createTray
function createTray(): void {
if (process.platform !== "win32") {
return;
}
tray = new Tray(path.join(__dirname, "src/assets/noia-icon.png"));
const contextMenu = Menu.buildFromTemplate([
{
label: "Show/Hide",
click: menuItem => {
if (win == null) {
return;
}
if (win.isVisible()) {
win.hide();
} else {
win.show();
}
}
},
{ type: "separator" },
{
label: "Quit",
click: menuItem => {
if (win != null) {
console.log("Window closed from context menu.");
win.destroy();
win = undefined;
}
}
}
]);
tray.setToolTip("NOIA Network Node");
tray.setContextMenu(contextMenu);
tray.on("click", () => {
if (win == null) {
return;
}
if (win.isVisible()) {
win.hide();
} else {
win.show();
}
});
}
示例10: buildTrayMenu
private buildTrayMenu() {
const contextMenu = Menu.buildFromTemplate([
{
click: () => WindowManager.showPrimaryWindow(),
label: locale.getText('trayOpen'),
},
{
click: () => lifecycle.quit(),
label: locale.getText('trayQuit'),
},
]);
if (this.trayIcon) {
this.trayIcon.on('click', () => WindowManager.showPrimaryWindow());
this.trayIcon.setContextMenu(contextMenu);
this.trayIcon.setToolTip(config.NAME);
}
}