如何在$文档正文p $ pvent点击事件(科尔多瓦也许一个错误?) [英] How to prevent click events on the document body (maybe a bug in Cordova?)

查看:114
本文介绍了如何在$文档正文p $ pvent点击事件(科尔多瓦也许一个错误?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个初学者试图建立一个手机游戏与动力学JS和PhoneGap的构建。我遇到一个问题,我不知道如何解决。 我做了一些测试:

I'm a beginner trying to develop a mobile phone game with with Kinetic Js and "phonegap build". I am experiencing a problem which I don't know how to address. I made some tests:

  1. 我刚刚粘贴<一href="http://www.html5canvastutorials.com/kineticjs/html5-canvas-drag-and-drop-events-tutorial/">this code这里到我的index.html和发送的code到的PhoneGap构建创造了APK从HTML code文件。 这个应用程序运行得很好,但如果你玩一点点,你可能会看到意外的行为:整个舞台可以用触摸来点击,当它发生(它实际上并不容易做到这一点的目的,但它发生),你听到Android操作系统的标准咔嗒声,并且看到整个区域突出显示一秒钟。就像如果你是在一个浏览器,你点击了一个链接。

  1. I just pasted this code here into my index.html and sent the code to the phonegap build which created the apk file from the html code. The app works quite fine but if you play a little bit you may see an undesired behavior: the entire "stage" can be clicked with a touch and when it happens (it's actually not easy to do it on purpose, but it happens) you hear the standard click sound of the android OS and you see the entire area highlighted for a second. Just like if you were in a browser and you clicked on a link.

我整理(用PhoneGap的版本)指南针模拟器链接这里,它的工作原理,但当你点击罗盘的PIC你触发了咔嗒声。这是一种不希望的效果是不是present,如果你在浏览器/仿真器中运行它。

I compiled (with phonegap build) the compass simulator linked here, it works but when you tap the pic of the compass you trigger the click sound. This is an undesired effect which is not present if you run it on a browser/emulator.

我只是把一些png图片身体避免帆布和KineticJs研究。我还没有添加任何脚本。在这种情况下,没有当你点击点击事件。但是,如果我添加

I just put some png image in the body avoiding canvas and KineticJs. I also didn't add any script. In this case there is no click event when you tap. But If I add

<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>

(甚至的没有的添加任何脚本),然后再次点击可以产生点击事件。如果我删除了两行的人那么单击事件消失。另外,如果我加入

(even without adding any script) then again tap can produce the click event. If I remove anyone of the two lines then the click event disappear. Also if I add

<script src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v4.5.4.min.js"></script>

再次对身体可点击的产生亮点,然后单击声音。 (我现在还在谈论用的PhoneGap构建编译应用程序)。

again the body is clickable producing highlights and click sound. (I'm still speaking about the compiled app with phonegap build).

我试图取代&LT;身体GT; &LT;身体onmousedown事件=返回false;&GT; 但没有帮助。我也试图与 $(#对象)点击(函数(){返回false;})。与画布,PIC和身体的div元素,没有帮助。我找了建议,使锚无法点击,看看他们是否可以应用,但我没有找到什么有用的东西。

I tried replacing <body> with <body onmousedown="return false;"> but didn't help. I also tried with $("#object").click( function () {return false;}) with the div element of the canvas, the pic and the body, didn't help either. I looked for advises to make anchors not clickable to see if they could be applied but I didn't find anything useful.

任何建议?

更新:闯闯这并没有解决的是: stage.off(轻点鼠标按下点击touchstart touchend dbltap');

Update: Another try which didn't solve is: stage.off('tap click mousedown touchstart touchend dbltap');.

推荐答案

您是否尝试过这个?

stage.on('tap touchstart touchend', function() {
  return false;
});

这也会有所帮助:

canvas {
  /*-webkit-tap-highlight-color: transparent; Some users reported this worked for them, although rgba(0,0,0,0); worked for the asker*/
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  outline: none;
}

下面是WebKit的触摸标注的快速链接,我不知道这是否会帮助你的情况......的http://phonegap-tips.com/articles/essential-phonegap-css-webkit-touch-callout.html

Here is a quick link on webkit-touch-callout, I'm not sure if it will help your situation... http://phonegap-tips.com/articles/essential-phonegap-css-webkit-touch-callout.html

编辑:看来电话的间隙,笔者建议 -webkit-自来水高亮颜色:RGBA(0,0,0,0)以prevent链路选择。来源这里: https://github.com/phonegap/ PhoneGap的启动/ BLOB /主/ WWW / CSS / index.css

It appears the author of phone gap suggests -webkit-tap-highlight-color: rgba(0, 0, 0, 0); to prevent link selection. Source here: https://github.com/phonegap/phonegap-start/blob/master/www/css/index.css

这篇关于如何在$文档正文p $ pvent点击事件(科尔多瓦也许一个错误?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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