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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
New Developer
Posts: 3
Registered: ‎12-31-2008
My Device: Not Specified
Accepted Solution

Javascript - Mouse Coordinates

Hello,

 

I'm using a Blackberry 9000 with the Hotspot Browser and I'm lokking for a way to get the mouse coordinates when the user clicks somewhere in the document. Something like event.clientX or event.pageX in other browsers...

 

Thanks in advance,

Marc

Developer
Posts: 107
Registered: ‎09-25-2008
My Device: Not Specified

Re: Javascript - Mouse Coordinates

Both clientX/clientY and screenX/screenY should work.

http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-MouseEvent

Do you have sample code that doesn't work?
Highlighted
New Developer
Posts: 3
Registered: ‎12-31-2008
My Device: Not Specified

Re: Javascript - Mouse Coordinates

Very fast reply. Thanks!

 

I found the problem with your hint. The problem are the events:

 

Works:

<img id="img" src="" onClick="mX=event.clientX;mY=event.clientY;">


Doesn't work:

document.ondblclick= ...;


Doesn't work:
<img id="img" src="" ondblclick="mX=event.clientX;mY=event.clientY;">

 

Do you know why ondblclick never fires?

 

Marc

 

Developer
Posts: 107
Registered: ‎09-25-2008
My Device: Not Specified

Re: Javascript - Mouse Coordinates

According to the guide at http://na.blackberry.com/eng/deliverables/5682/HTML_Reference.pdf the ondblclick attribute is not supported. I would imagine it's pretty hard to double-click using the trackball anyway, so maybe you could use single-clicks instead?
New Developer
Posts: 3
Registered: ‎12-31-2008
My Device: Not Specified

Re: Javascript - Mouse Coordinates

Yes, i can use a single click.

 

A last other question:

 

The Reference says that the "body" tag supports the "onkeypress" events, but this...

 

<body onkeypress="javascript&colonalert('Hello')">

 

.. didn't work. I was only able to get the  "onkeypress" event in an "input" tag?

 

Marc

 

 

 

Developer
Posts: 107
Registered: ‎09-25-2008
My Device: Not Specified

Re: Javascript - Mouse Coordinates

Hm, interesting. Most of the time when I pressed a key it activated a hotkey (e.g. pressing 's' brings up the settings), so I assume the keypress doesn't actually get to the page unless something on the page has focus. Since only input fields get focus, that's when you end up getting the keypress events.