Node-Webkit - Starting Maximized

懵懂的女人 提交于 2020-01-01 07:50:08

问题


I don't want a fullscreen application, but I would like to start a Node-Webkit application maximized. Can this be done? I am guessing its something to do with package.json, but can't seem to find what needs to be done.


回答1:


I don't think the manifest has an option to do that. Instead, call nw's Window.maximize() on startup. Something like:

// Load native UI library
var ngui = require('nw.gui');

// Get the current window
var nwin = ngui.Window.get();

Sometime later, in onload or some other point where you're ready to show the window:

onload = function() {
    nwin.show();
    nwin.maximize();
}

This is described in the node-webkit wiki. I don't think you can call maximize before showing the main window though (if it's hidden in manifest), but I haven't really dug into it.

You may want to consider saving the window position, from a UX standpoint. The wiki has an example for doing this.



来源:https://stackoverflow.com/questions/18423790/node-webkit-starting-maximized

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!