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
Contributor
cezeozue
Posts: 31
Registered: ‎01-06-2011
My Device: 9300
My Carrier: MTN Nigeria

Touch and keyboard events

Hi all,

 

I am unable to capture touch events in my Storm simulator and keyboard events in my Bold simulator.

 

For the touch events, I have tried document.ontouchstart, etc but it still does not respond. For the keyboard events, I don't even know where to start.

 

Help. Anyone?

Cheers!
Ezeozue Chidube
Seamfix Nigeria Limited (www.seamfix.com)
www.twitter.com/cezeozue
Please use plain text.
Developer
jmace
Posts: 482
Registered: ‎10-24-2008
My Device: 9300
My Carrier: AT&T

Re: Touch and keyboard events

I have a blog post up about capturing touch events. 

 

http://www.jasonmace.com/blackberry/?p=102

 

hopefully that will help a little bit.

_________________________________________
www.jasonmace.com/blackberry
Please use plain text.
Contributor
cezeozue
Posts: 31
Registered: ‎01-06-2011
My Device: 9300
My Carrier: MTN Nigeria

Re: Touch and keyboard events

Hello Jason,

 

Believe me I had read that post more that 3 times before your comment and once more just now to be sure I did not miss anything. I tried the suggested techniques to no avail. I fear that they may apply only to OS 6 devices and not OS 5.0 like Storm 2.

Cheers!
Ezeozue Chidube
Seamfix Nigeria Limited (www.seamfix.com)
www.twitter.com/cezeozue
Please use plain text.
Developer
jmace
Posts: 482
Registered: ‎10-24-2008
My Device: 9300
My Carrier: AT&T

Re: Touch and keyboard events

Ah sorry.

 

As far as the keyboard events, I haven't had any luck with those in the WebWorks arena. 

_________________________________________
www.jasonmace.com/blackberry
Please use plain text.
Contributor
cezeozue
Posts: 31
Registered: ‎01-06-2011
My Device: 9300
My Carrier: MTN Nigeria

Re: Touch and keyboard events

I've solved a part of it; the keyboard aspect.

 

I created a textfield with an onkeypress event. Enclosing the textfield within a hidden div made it invisible, then I forced it to constantly have focus too:

 

 

<div style="display: none">
   <input type="text" id="keyboardevents" onkeypress="javascript&colon;handleKeyPress(event);" onblur="javascript&colon; document.getElementById('focustest').focus();">
</div>

 

 

I also had to put  the following in the body onload attribute to ensure the textfield got focus once the page loaded:

 

 

document.getElementById('keyboardevents').focus();

 

Finally, the javascript function handleKeyPress(event):

 

 

function handleKeyPress(event) {
	alert("Key pressed: " + event.keyCode);
}

 

 

The keyCode's are numbers which I believe are ASCII.

 

I still haven't figured out the touch aspect for the storm yet though.

 

Cheers!
Ezeozue Chidube
Seamfix Nigeria Limited (www.seamfix.com)
www.twitter.com/cezeozue
Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Touch and keyboard events

Touch events are only supported starting with BlackBerry OS 6.0 and are not available on the Storm.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Contributor
cgishack
Posts: 12
Registered: ‎03-20-2011
My Device: 9800
My Carrier: none

Re: Touch and keyboard events

[quote]

Touch events are only supported starting with BlackBerry OS 6.0 and are not available on the Storm.

[end quote]

 

I have been trying to capture touch events with the Storm 9550 and its been driving me nuts. The simulators states to use the RIGHT mouse button to simulate touch. There is no way to capture touch events in the web development side of things (5.x OS)?

Please use plain text.
Administrator
astanley
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: Touch and keyboard events

I believe you will see the mouseclick events firing on the older OS 5.0 in place of the touchstart / touchend events (which as Tim indicated, became supported in BlackBerry 6).

 

So you can capture this type of user interaction, however it will be done so using the mouse events.  

 

To support both platforms, I would recommend defining *both* event handlers, but have them call a common handler method.  That way if your application ends up running on an OS that doesn't support the given touch event, it won't degrade in functionality.

 

Something like this:

 

 

function handleEvent(x, y)
{
  // do something ...
}

document.onmousedown = function(event) 
{
   handleEvent(event.clientX, event.clientY);
}

document.ontouchstart = function(event) 
{
   var touchEvent = event.changedTouches[0];
   handleEvent(touchEvent.pageX, touchEvent.pageY);
}

 

 

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Please use plain text.
Contributor
cgishack
Posts: 12
Registered: ‎03-20-2011
My Device: 9800
My Carrier: none

Re: Touch and keyboard events

[ Edited ]

I am trying to drag an Image around and am trying to move the image on touchmove/onmousemove too.

Does the Storm 9550 (v5.0.0517)  support element.onmousemove ?

I can't get that event to fire either.

Please use plain text.
Trusted Contributor
icecappacino
Posts: 152
Registered: ‎02-12-2011
My Device: Not Specified

Re: Touch and keyboard events

is it supported?
Please use plain text.