【发布时间】:2015-11-19 18:25:25
【问题描述】:
我意识到已经有几篇关于此的帖子(但 this one 或 this one 都没有得到答复)所以我想在这里提出/阐明这个问题。
我正在开发一个节点 webkit 应用程序(“nw”:“^0.12.3”)并且在启用触摸事件时遇到问题。以下代码在 Chrome/Chromium 中有效,但在 node webkit 中无效:
document.body.addEventListener('touchstart', function(e){
alert(e.changedTouches[0].pageX);
}, false);
我之前通过将“chromium-args”添加到我的 package.json (using this reference) 中启用了 nw 中的特定标志,我已经尝试在这种情况下做同样的事情(见下文)但似乎没有任何效果。 ..
"window": {
"toolbar": true,
"frame": true,
"icon": "icon.png",
"show_in_taskbar": false,
"chromium-args" : {
"--enable-touch-events" : true,
"--enable-pinch" : true,
"--enable-touch-drag-drop" : true,
"--touch-events" : true,
"--enable-touch-drag-drop" : true,
"--ash-touch-hud" : true
}
}
也(因为它的价值)
var nw = require('nw.gui');
nw.Screen.Init();
nw.Screen.screens[0].touchSupport; // returns 0
//...even though the monitor is a touchscreen ( Dell XPS )
【问题讨论】:
-
赞成。用于分享技巧。请分享更多这样的内容。
标签: javascript node.js webkit touch