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
Developer
barlowdot1
Posts: 35
Registered: ‎02-06-2011
My Device: bold 9900
Accepted Solution

Playbook touch events not working

The touch events on my app works perfect on the Ripple PlayBook Simulator but doesnt work on the PlayBook. Below is the code I apply. Does anyone know why?

 

var recX = 400;

var _origPos = -1;


try {
document.ontouchstart = startTouch;
document.ontouchend = endTouch;
} catch (err) {
alert('error' + err.description);
}

 

function startTouch(e) {
_origPos = e.screenX;
}

 

function endTouch(e) {
if(_origPos <= 630 && recX > 0){
recX = recX - 0;
}else
if (_origPos >= 631 && recX < 800) {
recX = recX + 0;
}
}

Please use plain text.
Developer
shanerooni
Posts: 39
Registered: ‎03-01-2011
My Device: PlayBook

Re: Playbook touch events not working

do you need to say startTouch() with the '()' so it knows it is a function? unable to test it at work.

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

Re: Playbook touch events not working

Use remote Web Inspector to identify what is happening wiht your code on the live device.  My guess is that this is the problem:

 

function startTouch(e) {
_origPos = e.screenX;
}

 


 

Would also suggest referencing the following sample that shows how to develop for PlayBook touch events: https://github.com/blackberry/WebWorks-Samples/blob/master/kitchenSink/js/browser/touch.js

 

Example:

 

function doTouchStart(event) {
    var touchEvent = event.changedTouches[0];
	var x = touchEvent.pageX;
	var y = touchEvent.pageY;
}

document.addEventListener("touchstart",  doTouchStart,  false);

 

 

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.