示例
- //获取当前窗口
- var win = nw.Window.get();
- // 监听最小化事件
- win.on('minimize', function() {
- console.log('Window is minimized');
- });
- // 窗口最小化
- win.minimize();
- // 移除最小化监听事件
- win.removeAllListeners('minimize');
- // 创建窗口并获取它的窗口对象
- nw.Window.open('https://github.com', {}, function(new_win) {
- // 监听新窗口焦点事件
- new_win.on('focus', function() {
- console.log('New window is focused');
- });
- });