Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Web and WebWorks Development

Reply
Developer
eblade
Posts: 132
Registered: 02-08-2012
My Carrier: None yet

Ripple: which is the correct event for taps/clicks?

In Ripple, on many of my clickable things, I am getting two events -- an "Object" that looks like an event, and a "MouseEvent".  Which is the correct one to be receiving?  

 

In other operating systems, I get one or the other, but not both.

 

 

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 410
Registered: 04-12-2010
My Carrier: Rogers

Re: Ripple: which is the correct event for taps/clicks?

Hi there,

 

Could you provide a small HTML sample page that produces this?

 

Erik Oros

BlackBerry Development Advisor

Erik Oros
BlackBerry Development Advisor
@WaterlooErik
Please use plain text.
Developer
eblade
Posts: 132
Registered: 02-08-2012
My Carrier: None yet

Re: Ripple: which is the correct event for taps/clicks?

<body onclick="doSomething();">
    <script>function doSomething(inSender, inEvent) { console.log(inEvent); }</script>
</body>

happens nearly all the time in Ripple, and occasionally on device emulator.  Lacking an answer to this question, I went ahead and ignored the one that wasn't a MouseEvent, and that seems to work pretty well at least in emulator.

 

Please use plain text.
BlackBerry Development Advisor
oros
Posts: 410
Registered: 04-12-2010
My Carrier: Rogers

Re: Ripple: which is the correct event for taps/clicks?

When I test this, I am actually getting inSender and inEvent logged as undefined which makes sense as the onclick is explicitly calling doSomething() without any parameters being passed in.

 

When I do something like the following though, note that only one paramater is being passed in (assigned to inSender) that is a MouseEvent. However inEvent remains undefined as expected.

 

<!DOCTYPE html>
<html>
	<head>
		<title>Sandbox</title>	
		<script>function doSomething(inSender, inEvent) { console.log(inSender); console.log(inEvent); }</script>
	</head>
	<body>
		<div id="foo">bar</div>
		<script type="text/javascript">
			document.getElementById("foo").onclick = doSomething;
		</script>
	</body>
</html>

The difference being that the onclick method is being assigned and called in a default manner (as opposed to us providing the explicit JavaScript for onclick.)

 

Just to make sure, are you using the latest version of the standalone Ripple software? (0.9.1 Beta, not the Chrome plug-in.)

 

Erik Oros

BlackBerry Development Advisor

Erik Oros
BlackBerry Development Advisor
@WaterlooErik
Please use plain text.