操纵和触摸事件不会触发,但是鼠标事件可以触发吗? [英] Manipulation and Touch events not firing, but mouse events do?

查看:142
本文介绍了操纵和触摸事件不会触发,但是鼠标事件可以触发吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台三星LD220Z多点触摸显示器,当我尝试使用某些WPF和触摸功能时,触摸事件不会触发.但是,鼠标按下事件似乎正在触发.

I have a Samsung LD220Z multi touch monitor, and when I'm experimenting with some WPF and touch features the touch events arent firing. The mouse down event seems to be firing however.

这是否意味着我必须考虑到并非所有触摸屏的行为都一样,如何在屏幕上获得触摸输入?我已经尝试了Microsoft发布的Windows 7 Touch Pack.而且多点触控功能似乎可以在其中使用.

Does this mean that I have to take into account that not all touch screen behave the same, and how do I get the touch inputs on my screen? I've tried the Windows 7 Touch pack that microsoft released. And the multi touch features seems to work there.

关于如何进行此操作的任何建议?

Any suggestion on how to proceed with this?

推荐答案

事件touchstart起作用,但touchend无效.您可以使用onmouseup ="SOMEfun()" 甚至三星Galaxy 3触发事件也存在问题. 添加第一个事件,thay将继续进行,但是 两种情况: 1)首先添加onmouseup,而不是tauchstart或更好 2)检查手机或台式机,然后添加适当的事件 您可以使用我的detectbrowser函数,该函数非常好(给定浏览器类型的名称,例如mobile_chrome_android_tablet或firefox_desktop,safari_ipad)

Event touchstart WORKS but touchend not. You can use onmouseup="SOMEfun()" Even the Samsung Galaxy 3 is a problem with the trigger event. Add the first event and thay will be working on but Two scenario : 1)first add onmouseup and than tauchstart or better 2)check mobile or desktop and than add proper events You can use my detectbrowser function , its very nice (give a name of browser type like mobile_chrome_android_tablet or firefox_desktop , safari_ipad)

使NOMOBILE全局化,您可以简单地替换var NOMOBILE = 0;与window ["NOMOBILE"] = 0;

Make NOMOBILE global , you can simply replace var NOMOBILE =0; with window["NOMOBILE"]=0;

下载浏览器和设备检测器: 检测浏览器和设备是否也可以

download browser and device detector : detect browser and device also class

类名是DETECTBROWSER()

Class name is DETECTBROWSER()

(在脚本的第一行)

var BROWSER =新的DETECTBROWSER()

var BROWSER = new DETECTBROWSER()

检查此BROWSER.NAME

Check this BROWSER.NAME

这甚至不是疯狂的脚本.同时跟踪10个手指(在canvas2d中) 链接: https://github.com/zlatnaspirala/multi-touch-canvas-handler

This is even crazy't script . Track 10 fingers at same time (in canvas2d) link : https://github.com/zlatnaspirala/multi-touch-canvas-handler

示例1)

      document.getElementById('myCanvas').addEventListener('touchstart', function(event) {
         event.preventDefault(); 
        var touch = event.touches[0]; 
        /* Avatar go left */
          if (touch.pageX < 235) {
        if (backgroundX < 0){
         left = 1;
         }
        /* Avatar go right */
         if (touch.pageX > 470) {
         right=1;
         }
        /* Avatar go lower distance */
         if (touch.pageX > 235 && touch.pageX < 470 && touch.pageY >250 ) {
         distance--;
         }
        /* Avatar go to high distance */
         if (touch.pageX > 235 && touch.pageX < 470 && touch.pageY <250 )  {
         distance++; 
        }
         } ,false);
        // solution for touchend
          function ENDoff(){

           if (moveLEFT==1) {  moveLEFT=0;  }
           if (moveRIGHT==1) { moveRIGHT=0;  }
          }

HTML CODE 
<canvas id="myCanvas" width="480" height="960" onmouseup="touch_UP();"></canvas>

这篇关于操纵和触摸事件不会触发,但是鼠标事件可以触发吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆