Electron enable touch events for a touch screen

﹥>﹥吖頭↗ 提交于 2019-12-11 01:47:07

问题


I have a Raspberry Pi connected to touchscreen and running an electron app on it through the startx command,

# startx ./electron-app -- --nocursor

the problem that I can't handle the touch events like (touchstart, touchend) and apparently that is because Electron (or chromium) not seeing the screen as a touch screen.


回答1:


The problem is not that Electron/Blink isn't seeing the touchscreen / native touch events. There are two parts to the problem, as I understand it:

  1. You need to ensure you're receiving touch events in the OS from the touchscreen. I haven't tested with Pi/Linux, so I'm not sure if those handle touch events natively. I know that OSX, for one, requires a third-party driver like [UDPP by Touch-Base.
  2. Once the OS is handling touch events, those are piped through to Blink via the Electron wrapper. However, you need to set the touch-events command-line switch to enable it. My understanding is that that switch is passed through as a Chromium commandline switch.

I found more info on this thread, though not very much, and still haven't gotten things working on my OSX setup. Electron's documentation is very sparse...the touch-events switch isn't even listed in their CLI docs. Hope this helps.



来源:https://stackoverflow.com/questions/40359462/electron-enable-touch-events-for-a-touch-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!