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

Reply
Developer
gdev001
Posts: 163
Registered: ‎01-30-2013
My Device: Blackberry 10 Simulator

Simulating Clicked event using onTouch

Hi,

 

I have overriden a onTouch event for my container. What I want basically

is to respond to "clicks" on my container (just like button clicks). How

to achieve similar functionality to a "click" using the onTouch????

 

I mean how to know, using an onTouch, that an action similar to "click" has occured???

 

When I have purely

onTouch { .. some action ... }

 I think this gets called twice, once when the user clicks the container area, and second time, once the user

releases the mouse button.

Please use plain text.
Contributor
chriske86
Posts: 43
Registered: ‎01-05-2013
My Device: Dev Alpha
My Carrier: Telenor Hungary

Re: Simulating Clicked event using onTouch

Hi,

 

here is the reference for onToch with some sample codes:

 

http://developer.blackberry.com/cascades/documentation/dev/touch/touch_propagation.html

 

cheers,

chriske

--------------------------------------------------------------
If my post was helpful or it was the solution for Your problem, please don't forget to give me a like, and mark my post as a solution. Thanks!
Please use plain text.
New Developer
Watman
Posts: 15
Registered: ‎02-12-2013
My Device: Bold 9900 - Z10 LE - DAC - Playbook

Re: Simulating Clicked event using onTouch

What about using the TapHandler as a gestureHanlder on your container ... works fine for my usecase.

Container{

gestureHandlers: [
            TapHandler {
                onTapped: {
                        ... some action ...

                   }
                }
            }
        ]

}

---------------------------------------------------------------------------------------------
Prompter: BlackBerry World - Built for BlackBerry™
Prompter4Q: BlackBerry World - Built for BlackBerry™
Please use plain text.
Developer
gdev001
Posts: 163
Registered: ‎01-30-2013
My Device: Blackberry 10 Simulator

Re: Simulating Clicked event using onTouch

I am not sure which is better, more common. I guess i will have a look at both. btw. OnTapped -- is it similar to a "clicked" event? e..g, like with buttons? thanks.
Please use plain text.
New Developer
Watman
Posts: 15
Registered: ‎02-12-2013
My Device: Bold 9900 - Z10 LE - DAC - Playbook

Re: Simulating Clicked event using onTouch

As far as i'm aware, there is no "up" or "down" state like you have with the onTouch (cfr your calling twice of the event), but do correct me if i'm wrong ("new" developer on this OS).

More info can be found here: http://developer.blackberry.com/cascades/documentation/dev/touch/index.html

You can also add DoubleTapHandlers and LongPressHandlers to differentiate various scenario's/gestures.

---------------------------------------------------------------------------------------------
Prompter: BlackBerry World - Built for BlackBerry™
Prompter4Q: BlackBerry World - Built for BlackBerry™
Please use plain text.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Simulating Clicked event using onTouch

Hi,

 

These events can be differentiated:

 

onTouch: {
  if (event.isDown()) {
    // ...
  }
}

 


Andrey Fidrya, @zmeyc on twitter
Please use plain text.