我看这个node-webkit 教程,这个视频在解决自定义最大化最小化的时候用window.on(‘maximize’)监听窗口的变化,但是Window的监听函数好像都没有监听到,使得最大化以后不能恢复,不知道为什么,我把源码复制下来还是一样的,一开始我以为是API变了,但是还是没发现什么不同,window.on(‘minimize’)还是没发现能监听成功,-
是最小化,o
最大化,x
是关闭,求助:
<!DOCTYPE html>
<html>
<head>
<title>Turbo</title>
<script>
var nw = require('nw.gui');
var win = nw.Window.get();
win.isMaximized = false;
</script>
</head>
<body>
<header>
<ul>
<li><a href='#' title='Minimize' id='windowControlMinimize'>-</a></li><!--
--><li><a href='#' title='Maximize' id='windowControlMaximize'>o</a></li><!--
--><li><a href='#' title='Close' id='windowControlClose' >x</a></li>
</ul>
</header>
<script>
// Min
document.getElementById('windowControlMinimize').onclick = function()
{
win.minimize();
};
// Close
document.getElementById('windowControlClose').onclick = function()
{
win.close();
};
// Max
document.getElementById('windowControlMaximize').onclick = function()
{
if (win.isMaximized)
win.unmaximize();
else
win.maximize();
};
// Listen to the minimize event
win.on('minimize', function() {
console.log('Window is minimized');
});
win.on('maximize', function(){
win.isMaximized = true;
});
win.on('unmaximize', function(){
win.isMaximized = false;
});
</script>
</body>
</html>