2015-11-19 86 views
1

我知道这里已经有几个帖子(但是this onethis one都没有回答),所以我想问一下/在这里说明问题。节点webkit(nw)中的触摸事件

我正在开发一个节点webkit应用程序(“nw”:“^ 0.12.3”)并且存在启用触摸事件的问题。下面的代码工作在铬/铬,但不是在节点的webkit:

document.body.addEventListener('touchstart', function(e){ 
    alert(e.changedTouches[0].pageX); 
}, false); 

我之前加入“铬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) 
+0

了投票。分享技巧。请分享更多这样的内容。 – YumYumYum

回答

1

物业chromium-args是放错了地方的d它有错误的格式。

{ 
    "name": "Test aoo", 
    "version": "0.0.0", 
    "main": "index.html", 
    "window": { 
    "frame": false, 
    "toolbar": false 
    }, 
    "chromium-args": "--touch-events --enable-touch-drag-drop", 
} 

与测试:

console.log('ontouchstart' in window); 
+0

我的印象是这两种格式的工作,但无论哪种方式,我试过这种方法(因为它是在我上面引用的其他两个堆栈帖子之一建议)可悲的是,它不适合我。你自己试过了吗?如果是的话(以及它是否有效),你能告诉我你使用的是哪个版本的node-webkit吗?以及你使用过什么类型的设备? – Nick

+0

我正在使用nw-v0.12.3。我正在使用http://www.alibaba.com/product-detail/low-cost-22-lcd-usb-touch_60277186843.html,但也在带有触摸屏的笔记本电脑上进行测试。 – DinkoM

+0

我在戴尔XPS上的Linux(Ubuntu 14.04)上http://www.dell.com/us/business/p/xps-13-linux/pd?oc=cax13ubuntus5122v&model_id=xps-13-linux&l=zh-CN&s= bsd >>你在用什么笔记本电脑/操作系统? – Nick