Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Member
jeet232
Posts: 1
Registered: ‎11-17-2012
My Device: None
My Carrier: NA

Touch events not working

I'm using this as the first page for my webworks app, but simulator does not process any touch events.

 

<!DOCTYPE html>
<html>
<head>
    <title>Game</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta id="viewport" name="viewport" content="user-scalable=no,width=768,height=1280" />
	<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
 
<body style='background:url(images/road.png) no-repeat'>

	<script language='javascript'>
	function doTouchStart(e) {
		window.alert("hi");
	}
	
	document.addEventListener("touchstart",  function(e) { window.alert("hello"); },  false);
	
	</script>
	
	<div id='container'>
	<div id='bgmusic'><audio src="sounds/title.mp3" autoplay autobuffer></audio></div>
	<div id='privacy' style='text-align:center;display:none'>
		<div><h1>Privacy Policy</h1><div>blah blah blah blah</div></div>
		<div><a href=#><img src='images/back-button.png'/></a></div>
	</div>
	<div id='controls'>
		<h1 style='margin:0 auto;text-align:center;margin-top:100px;font-size:60px;color:white'><img src='images/logo.png'/></h1>
		<div style='margin-top:50px;text-align:center'>
			<a href='#' id="btnPlay"><img src='images/btn-play.png'/></a>			
		</div>    
		<div style='float:right'>
			<a href=# id="btnPlay">Privacy Policy</a>			
		</div>
		<div style='clear:both'></div>
	</div>
	</div>
</body>
</html>

 what is going wrong here?

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Touch events not working

Made just a few slight modifications, and am seeing the alert successfully trigger in Ripple. Testing simulator next.

 

<!DOCTYPE html>
<html>
	<head>
		<title>Game</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta id="viewport" name="viewport" content="user-scalable=no,width=768,height=1280" />
		<link href="styles.css" rel="stylesheet" type="text/css" />
	</head>
	<body style='background:url(images/road.png) no-repeat;'>

		<script language='javascript'>
			function doTouchStart(e) {
				window.alert("hi");
			}

			document.addEventListener("touchstart",  function (e) { window.alert("hello"); },  false);
		</script>
		
		<div id='container'>
		<div id='bgmusic'><audio src="sounds/title.mp3" autoplay autobuffer></audio></div>
		<div id='privacy' style='text-align: center; display: none;'>
			<div><h1>Privacy Policy</h1><div>blah blah blah blah</div></div>
			<div><a href="#"><img src='images/back-button.png'/></a></div>
		</div>
		<div id='controls'>
			<h1 style='margin: 0 auto; text-align: center; margin-top: 100px; font-size: 60px; color: white;'><img src='images/logo.png'/></h1>
			<div style='margin-top: 50px; text-align:center;'>
				<a href="#" id="btnPlay1"><img src='images/btn-play.png'/></a>			
			</div>    
			<div style='float: right;'>
				<a href="#" id="btnPlay2">Privacy Policy</a>			
			</div>
			<div style='clear: both;'></div>
		</div>
		</div>
	</body>
</html>

 

Changes:

  • Fixed a few href=# properties.
  • Made element ids unique.

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Touch events not working

Just tested in a simulator, and the touch event is triggering just fine as well.


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Touch events not working

Adding BAR file. Please rename to .bar


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
Please use plain text.