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

Native 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
Developer
Posts: 49
Registered: ‎06-06-2012
My Device: Bold 9700
My Carrier: Pelephone
Accepted Solution

Touch event handling - Parents and Children

I have a container containing some controls.

 

What I would like is that the container's onTouch code only execute if no child control handled the onTouch event.

 

Is this possible?

 

Thanks,

 

Jamie

Retired
Posts: 138
Registered: ‎05-11-2012
My Device: Developer
My Carrier: Developer

Re: Touch event handling - Parents and Children

https://developer.blackberry.com/cascades/reference/bb__cascades__visualnode.html#touchpropagationmo...

 

Provides the best description of the touch propagation that I can find. Not totally sure that this will provide you with what you are required so you might have to control it deliberately but this should hopefully provide you with the description of what is currently implemented.

 

Graham

Developer
Posts: 49
Registered: ‎06-06-2012
My Device: Bold 9700
My Carrier: Pelephone

Re: Touch event handling - Parents and Children

Thanks for the link.

 

I've read this many times before. As far as I understand this only allows me to control which controls will get the events. 

Developer
Posts: 49
Registered: ‎06-06-2012
My Device: Bold 9700
My Carrier: Pelephone

Re: Touch event handling - Parents and Children

I solved it.

 

Here's how...

 

First of all, there are two touch events, which I now I understand as follows:

 

"touchCapture" is received in a container before the propagation to the children takes place.

"touch" is received in a container after the propagation takes place.

 

I added a property to the container like this:

 

property bool touchHandled

 

I added handlers for both touchCapture and touch, like this:

 

onTouchCapture: {
  touchHandled = false
}

onTouch: {
  if (!touchHandled) {
    //Handle as desired..
  }
}

 

If a child control handles the touch event, I have the child set touchHandled to true. For example, in one of the children, I handle an UP event. I code it like this (in the child):

 

onTouch: {
  if (event.isUp()) {
    //Do whatever...

    touchHandled = true
  }
}

 

Mission accomplished. Comments are welcome...

 

Jamie

 

 

Highlighted
Retired
Posts: 138
Registered: ‎05-11-2012
My Device: Developer
My Carrier: Developer

Re: Touch event handling - Parents and Children

Hi Jamie,

 

That looks like a good and neat solution, Congrats.

 

Graham