界面相关操作
以下各类均继承自类Base
1.菜单(menu)
(1)void Create(const base::DictionaryValue& option);
(2)void Destroy();
(3)void Append(MenuItem* menu_item);
(4)void Insert(MenuItem* menu_item, int pos);
(5)void Remove(MenuItem* menu_item, int pos);
(6)void Popup(int x, int y, content::Shell*);
注:所有方法均为异步操作
JavaScript实例:
var gui = require('nw.gui');
var menu = new gui.Menu();
2.菜单项(menuitem)
(1)void Create(const base::DictionaryValue& option);
(2)void Destroy();
(3)void SetLabel(const std::string& label);
(4)void SetIcon(const std::string& icon);
(5)void SetTooltip(const std::string& tooltip);
(6)void SetEnabled(bool enabled);
(7)void SetChecked(bool checked);
(8)void SetSubmenu(Menu* sub_menu);
注:所有方法均为异步操作
JavaScript实例:
var gui = require('nw.gui');
var menuItem = new gui.MenuItem({ label: 'Item 3' });
3.托盘(Tray)
(1)void Create(const base::DictionaryValue& option);
(2)void ShowAfterCreate();
(3)void Destroy();
(4)void SetTitle(const std::string& title);
(5)void SetIcon(const std::string& icon_path);
(6)void SetTooltip(const std::string& title);
(7)void SetMenu(Menu* menu);
(8)void Remove();
(9)void SetAltIcon(const std::string& alticon_path);// Alternate icons only work with Macs
注:所有方法均为异步操作
JavaScript实例:
var gui = require('nw.gui');
var tray = new gui.Tray({ title: 'Test Menu', menu: menu });
4.窗口(Window)
异步操作:
(1)Show
(2)Close
(3)Hide
(4)Maximize
(5)Unmaximize
(6)Minimize
(7)Restore
(8)EnterFullscreen
(9)LeaveFullscreen
(10)ToggleFullscreen(切换全屏)
(11)EnterKioskMode(只显示网页以及必要的滚动条)
(12)LeaveKioskMode
(13)ToggleKioskMode
(14)ShowDevTools(打开“审查元素”窗口)
(15)CloseDevTools
(16)ResizeTo
(17)SetMaximumSize
(18)SetMinimumSize
(19)SetResizable
(20)SetAlwaysOnTop
(21)MoveTo
(22)RequestAttention(FlashFrame)
(23)SetMenu
(24)Reload
(25)CapturePage
同步操作:
(1)IsFullscreen
(2)IsKioskMode
(3)GetSize
(4)GetPosition
(5)IsDevToolsOpen
JavaScript实例:
var gui = require('nw.gui');
var win = gui.Window.get();
系统资源操作
以下各类均继承自类Base
1.剪贴板
异步操作:
void SetText(std::string& text);
void Clear();
同步操作:
std::string GetText();
node-webkit工程搭建:http://blog.csdn.net/glt3953/article/details/12510923