2015-11-19 82 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