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
razorek
Posts: 64
Registered: ‎06-28-2012
My Device: BlackBerry Z10LE
My Carrier: T-Mobile
Accepted Solution

Touch events not being fired if interaction started off the top bezel

[ Edited ]

Hi,

 

I'm developing a HTML5 / WebWorks game. The user has to touch and move around items to complete the game.

 

I've noticed, that when the touch starts from the top bezel and the finger moves down on to the screen, no touch events are being fired.

If an item is near the top of the screen, it's actually quite frequent, that the device considers that a touch started off the bezel, and the app is completely unaware about the finger movement.

 

Is there any way to tell the webworks engine not to consume the events if they started off the top bezel?

They all get fired if I touch from the left / right bezel.

 

I will greatly appreciate any help!

Please use plain text.
BlackBerry Development Advisor
chadtatro
Posts: 614
Registered: ‎10-01-2009
My Device: Z10
My Carrier: Bell

Re: Touch events not being fired if interaction started off the top bezel

Hello,

 

Couple things come to mind here...

 

1. I'm wondering the device is listening for a 'swipedown' event, which is used for the Application Menu.

 

2. Would you mind sharing how you've setup your event listener for touches?

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Please use plain text.
Developer
razorek
Posts: 64
Registered: ‎06-28-2012
My Device: BlackBerry Z10LE
My Carrier: T-Mobile

Re: Touch events not being fired if interaction started off the top bezel

Hello Chad, thank you for an answer :smileyhappy:.

 

1. It's true, that the device sends a 'swipedown' event. If I listen for this event I get notified of it, but I don't get any touch events. I suppose that the swipedown event consumes any subsequent touch events?

 

2. Here is my event setup code. I've tested it with container being the body element and the result is the same: no events if the touch actions starts off the top bezel.

 

container.addEventListener("touchstart", mouseDownOrTouchStart);

container.addEventListener("touchmove", mouseOrTouchMove);

container.addEventListener("touchend", mouseUpOrTouchEnd);

container.addEventListener("touchcancel", touchCancel);

 

 

And touchmove event:

function mouseOrTouchMove(e) {

console.log("move");

e.preventDefault();

var pageX;

var pageY;

 

if(isTouch) {

pageX = e.changedTouches[0].pageX;

pageY = e.changedTouches[0].pageY;

}

else{

pageX = e.pageX;

pageY = e.pageY;

}

//... ... ...

}

 

-------------------------

In Cascades, the UI clearly "knows" where the finger is even after a swipedown event - the application menu follows your finger movement. But in WebWorks, touch events after swipedown seem to be gone :smileysad:

Please use plain text.
Developer
razorek
Posts: 64
Registered: ‎06-28-2012
My Device: BlackBerry Z10LE
My Carrier: T-Mobile

Re: Touch events not being fired if interaction started off the top bezel

[ Edited ]

Just as a reference: I've managed to make it work, so that I revceive touch events even if the interaction starts of the top bezel.

 

I've converted the app to hybrid and push touch events form cascades to the WebView control. It's a lot of work, but it's doable :smileyhappy:.

 

Best regards :smileyhappy:!

Please use plain text.