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
New Contributor
Posts: 8
Registered: ‎05-03-2011
My Device: Playbook
My Carrier: N/A

Playbook - onclick event not firing

[ Edited ]

I am developing an application for the Playbook. onclick events appear not to be firing in my WebWorks application. I have tested on both the simulator and device with the same result. Any suggestions would be great.

Developer
Posts: 482
Registered: ‎10-24-2008
My Device: 9300
My Carrier: AT&T

Re: Playbook - onclick event not firing

have you tried the ontouchstart and ontouchend events?

_________________________________________
www.jasonmace.com/blackberry
New Contributor
Posts: 8
Registered: ‎05-03-2011
My Device: Playbook
My Carrier: N/A

Re: Playbook - onclick event not firing

I'm currently using ontouchstart & ontouchmove within the application and they are working as expected. I've not used ontouchend yet but imagine it would probably work too. Is there any reason for onclick not working? I guess I could simulate my own onclick using ontouchstart and ontouchend however I'd like to avoid this if it's not necessary.

Developer
Posts: 482
Registered: ‎10-24-2008
My Device: 9300
My Carrier: AT&T

Re: Playbook - onclick event not firing

I think that an onclick event should be fired shortly after a touchstart/touchend combination...again, I think. I remember reading an article about using touchstart/touchend instead  because they were fired milliseconds before onclick.

 

have you tried some test code just to double check everything? something like this...

 

 

document.onclick = function(){ alert('onclick fired')};
document.ontouchend= function(){ alert('ontouchend fired')};

 

Can I ask what element you are trying to capture an onclick for?

 

 

Some older research on which interactions browsers support

http://www.quirksmode.org/mobile/tableTouch.html

_________________________________________
www.jasonmace.com/blackberry
New Contributor
Posts: 8
Registered: ‎05-03-2011
My Device: Playbook
My Carrier: N/A

Re: Playbook - onclick event not firing

Thanks jmace,

 

that solved the problem. It was because I had event.preventDefault() in ontouchstart. Basically I'm implementing a touch carousel. The user can scroll the carousel horizontally by swiping left and right. When they tap an item in the carousel I want to display some new content. I was using onclick to listen for the tap of an item however now I see that this won't work. Instead would it be a good idea to use ontouchstart & ontouchend to register a tap? i.e. check if the change in touch position between these two events is smaller than some threshold. Or am I going about this completely wrong? Thanks again for the help Smiley Happy

Developer
Posts: 482
Registered: ‎10-24-2008
My Device: 9300
My Carrier: AT&T

Re: Playbook - onclick event not firing

I think you are right on the money. I did the same thing in a webworks phone application (carousel to choose an item.

 

capture a delta x and delta y, and if it is within a small amount, I would call it a tap. You can also capture the datetime of the event and start to build touch events for a touch hold (pop up a menu) or a double tap.

_________________________________________
www.jasonmace.com/blackberry
New Contributor
Posts: 8
Registered: ‎05-03-2011
My Device: Playbook
My Carrier: N/A

Re: Playbook - onclick event not firing

Thanks jmace, you've been a great help!