首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >nw.js如何全屏转义

nw.js如何全屏转义
EN

Stack Overflow用户
提问于 2017-03-05 02:32:16
回答 3查看 889关注 0票数 0

我正在使用nw.js生成一个可执行文件。我可以将其设置为全屏模式,但如何使用退出键对其进行转义?人们建议使用下面的代码,但是我应该把它放到哪个文件中呢?

代码语言:javascript
复制
var gui = window.requireNode('nw.gui');
gui.App.registerGlobalHotKey(new gui.Shortcut({
  key: "Esc",
  active: function () {
    gui.Window.get().leaveFullscreen();
  })
}));
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2017-03-05 18:25:06

官方建议在文档中使用以下方式:http://docs.nwjs.io/en/latest/For%20Users/FAQ/

您必须注册一个全局热键:

代码语言:javascript
复制
nw.App.registerGlobalHotKey(new nw.Shortcut({
  key: "Escape",
  active: function () {
    // decide whether to leave fullscreen mode
    // then ...
    nw.Window.get().leaveFullscreen();
  }
}));

您可以将此代码片段放在应用程序的开头。

代码语言:javascript
复制
<!DOCTYPE html>
<html>
<head>
  <script>
nw.App.registerGlobalHotKey(new nw.Shortcut({
  key: "Escape",
  active: function () {
    // decide whether to leave fullscreen mode
    // then ...
    nw.Window.get().leaveFullscreen();
  }
}));
  </script>
</head>
<body>
</body>
</html>
票数 1
EN

Stack Overflow用户

发布于 2017-08-26 08:07:24

您可以使用此选项退出firescreen

代码语言:javascript
复制
<!DOCTYPE html>
<html>
<head>
  <script>
  var gui = require('nw.gui');
  gui.App.registerGlobalHotKey(new nw.Shortcut({
  key: "Escape",
  active: function () {
    // decide whether to leave fullscreen mode
    // then ...
    nw.Window.get().leaveFullscreen();
    }
    }));
    </script>
</head>
<body>
</body>
</html>

并执行以下操作以切换firescreen:

代码语言:javascript
复制
<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
  <script>
	var gui = require('nw.gui');	
	gui.App.registerGlobalHotKey(new gui.Shortcut({
	key: "F11",
	active: function () {
    // decide whether to leave fullscreen mode
    // then ...
    gui.Window.get().toggleFullscreen();
	}
	}));
  </script>
  </body>
 </html>

票数 0
EN

Stack Overflow用户

发布于 2017-08-28 01:10:49

您可以使用此选项退出全屏

代码语言:javascript
复制
<!DOCTYPE html>
<html>
<head>
  <script>
  var gui = require('nw.gui');
  gui.App.registerGlobalHotKey(new nw.Shortcut({
  key: "Escape",
  active: function () {
    // decide whether to leave fullscreen mode
    // then ...
    gui.Window.get().leaveFullscreen();
    }
    }));
    </script>
</head>
<body>
</body>
</html>

使用此命令可切换全屏:

代码语言:javascript
复制
<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
  <script>
	var gui = require('nw.gui');	
	gui.App.registerGlobalHotKey(new gui.Shortcut({
	key: "F11",
	active: function () {
    // decide whether to leave fullscreen mode
    // then ...
    gui.Window.get().toggleFullscreen();
	}
	}));
  </script>
  </body>
 </html>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42599764

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档