【问题标题】:Style system tray with node-webkit application使用 node-webkit 应用程序样式系统托盘
【发布时间】:2015-03-04 11:28:51
【问题描述】:

我正在使用node-webkit 构建一个具有系统托盘菜单的后台Windows 应用程序。我希望能够构建一个系统托盘菜单,它比带有复选框的下拉菜单更复杂;更类似于 Dropbox:

nw.js's docs 中没有提到系统托盘的样式。如何使用 nw.js 做到这一点?

如果不是 nw.js,还有哪些其他语言/框架更适合做这样的事情?

【问题讨论】:

标签: windows node.js node-webkit system-tray


【解决方案1】:

首先创建一个窗口。并在托盘上单击让此窗口出现在那里。

var gui = require('nw.gui');
var tray = new gui.Tray({
    title: '',
    icon: 'assets/css/images/menu_icon.png',
    alticon: 'assets/css/images/menu_alticon.png',
    iconsAreTemplates: false
});

//Then need create hidden window and show it on click in tray:

// create window

var params = {toolbar: app.devMode, frame: false, transparent: true, resizable: false, show: false};
window = gui.Window.open('templates/panel.html', params);

function showPopup (x, y) {
  window.on('document-end', function(){
    window.moveTo(x - (window.window.width / 2) - 6, y);
    window.show();
    window.focus();
  });
}

// show panel when click in tray
tray.on('click', function (evt) {
  showPopup(evt.x, evt.y);
});

希望这行得通!

参考:Create window-like menu on OS X

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-10-06
    • 2012-09-16
    • 1970-01-01
    • 1970-01-01
    • 2013-03-14
    • 2011-05-22
    • 2016-09-03
    相关资源
    最近更新 更多