[英]Phonegap Touch Event Handling
I am trying to make a calculator using phonegap - but I am running into problems in adding the touch event. 我正在尝试使用phonegap制作计算器 - 但我在添加触摸事件时遇到了问题。 It does not show anything on the display. 它在显示屏上没有显示任何内容。 kindly see if there are problems in the code. 请注意代码中是否存在问题。 and suggest me a solution. 并建议我一个解决方案。 **I have added the onTouch
event to all the numbers and math operators buttons. **我已将onTouch
事件添加到所有数字和数学运算符按钮。
function onload(){
document.getElementById("display").addEventListener('onTouch',insert,false);
document.getElementById("clear").addEventListener('onClear', clear, false);
document.getElementById("equal")addEventListener('onEqual', evaluate,false);
}
function clear(){
document.getElementById("display").value="";
return false;
}
function insert(val){
document.getElementById("display").value+=val;
}
function evaluate(){
try
{
ans= eval(document.getElementById("display").value);
document.getElementById("display")=ans;
return false;
}
catch
{
document.getElementById("display").value="Error";
return false;
}
}
I am not sure about the onTouch
event. 我不确定onTouch
事件。 Does that exist at all? 这根本存在吗?
I would suggest to try either touchstart
or touchend
maybe touchmove
event handlers. 我建议尝试touchstart
或touchend
也许touchmove
事件处理程序。 These should work. 这些应该有效。 For example: 例如:
document.getElementById("display").addEventListener('touchstart',insert,false);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.