【问题标题】:touch events in node webkit ( nw )节点 webkit ( nw ) 中的触摸事件
【发布时间】:2015-11-19 18:25:25
【问题描述】:

我意识到已经有几篇关于此的帖子(但 this onethis 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


【解决方案1】:

属性chromium-args 位置错误,格式错误。

{
  "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);

【讨论】:

  • 我的印象是这两种格式都有效,但无论哪种方式,我都尝试过这种方法(正如我在上面引用的其他两个堆栈帖子之一中所建议的那样),遗憾的是,它不起作用为了我。你自己试过吗?如果是这样(如果它有效)你能告诉我你使用的是哪个版本的 node-webkit 吗?你在什么设备上使用它?
  • 我使用的是 nw-v0.12.3。我正在使用alibaba.com/product-detail/…,但也在带触摸屏的笔记本电脑上进行了测试。
  • 我在戴尔 XPS 上使用 Linux (Ubuntu 14.04) dell.com/us/business/p/xps-13-linux/… >> 你在使用什么笔记本电脑/操作系统?
  • 我使用的是 ubuntu 14.04/fedora。笔记本电脑是华硕 ZenBook。
猜你喜欢
  • 2014-05-19
  • 2023-03-27
  • 1970-01-01
  • 2013-08-11
  • 2012-12-13
  • 1970-01-01
  • 2011-12-07
  • 1970-01-01
  • 2011-11-03
相关资源
最近更新 更多