开发者

Manipulation and Touch events not firing, but mouse events do?

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.

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开发者_StackOverflow社区 7 Touch pack that microsoft released. And the multi touch features seems to work there.

Any suggestion on how to proceed with this?


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)

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

Class name is DETECTBROWSER()

(on first line in script)

var BROWSER = new DETECTBROWSER()

Check this BROWSER.NAME

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

example for 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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜