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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Contributor
schumi1331
Posts: 21
Registered: ‎11-15-2012
My Carrier: E-Plus
Accepted Solution

Touch Events in Cascades/QML

Hello everyone :smileyhappy:

 

I'm brandnew in this Cascades stuff and lot is different than in QtQuick on Symbian, that's why I have one, well two small questions:

 

1) How can I handle touch events. For example I want to design an element in form of a button, but without using the predefined one. Basically it is a container with color and a label in it. And I want to give a basic animation, so I'm looking for two methods equal to onPressed and onReleased, to change the background color, when the user presses on the button, and to return it to the default color, when he releases it.

 

2) Is there any kind of Qt Assistant for Cascades? I could only find the online help/API reference here, but it is so messed up in my opinion and functions like searching are missing. In the best case this documentation is downloadable and usable fully offline.

 

I hope, you can help me... :smileyhappy:


Best Regards,

Sebastian

Please use plain text.
Developer
kylefowler
Posts: 479
Registered: ‎05-17-2009
My Carrier: ATT

Re: Touch Events in Cascades/QML

Each item has a touch signal that you can attach a slot to or in qml just do onTouch: { }
Like all of my posts
Please use plain text.
Contributor
schumi1331
Posts: 21
Registered: ‎11-15-2012
My Carrier: E-Plus

Re: Touch Events in Cascades/QML

Tried that as well, but the result is, that the button changes the color when I release the button only. How to do get, that the button was pressed OR released? This is the part I don't understand...

Please use plain text.
Developer
simon_hain
Posts: 13,775
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: Touch Events in Cascades/QML

I worked on a similar issue today. You can query the type of the touch event like this:

onTouch: {
    if (event.touchType == TouchType.Down) {
      //doStuff     
    }
}

 I used this to make a whole container to a button, regardless of its content.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
kylefowler
Posts: 479
Registered: ‎05-17-2009
My Carrier: ATT

Re: Touch Events in Cascades/QML

theres also helper methods.

event.isDown()
event.isMove()
event.isUp()
Like all of my posts
Please use plain text.
Developer
bcs925
Posts: 212
Registered: ‎07-13-2012
My Carrier: T-Mobile

Re: Touch Events in Cascades/QML

I have found it best to create the custom components then tie a gestureHandlers to it, to mimic a single "onTouch" you would use the "onTapped" gesture. However not sure if you can have an isUp or isDown event on that gesture so i dont know if you'll be able to have the button look like it is "being pressed".

---
Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan
Please use plain text.
Trusted Contributor
gdev001
Posts: 163
Registered: ‎01-30-2013

Re: Touch Events in Cascades/QML

Hello,

 

I have exactly the same problem as your problem #1.

i.e.,

1) How can I handle touch events. For example I want to design an element in form of a button, but without using the predefined one. Basically it is a container with color and a label in it. And I want to give a basic animation, so I'm looking for two methods equal to onPressed and onReleased, to change the background color, when the user presses on the button, and to return it to the default color, when he releases it.

 

Could you please tell me how/if you solved it???

Thanks.

Please use plain text.
Developer
simon_hain
Posts: 13,775
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: Touch Events in Cascades/QML

please open a new thread for your issue. you can link relevant threads if you want.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.