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
tanphat1412
Posts: 125
Registered: ‎11-06-2012
My Device: BlackBerry
My Carrier: Mobifone
Accepted Solution

Problem with slot onTouch in ImageView.

When I make a count function to get how many times a picture is touched.

But when i touch picture just 1 time, but the function show 2.

I don't know what is going on. Please help.

Thanks.

Please use plain text.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Problem with slot onTouch in ImageView.

Can you post the relevant code please?

Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Developer
tanphat1412
Posts: 125
Registered: ‎11-06-2012
My Device: BlackBerry
My Carrier: Mobifone

Re: Problem with slot onTouch in ImageView.

ImageView {
	id: image01
	imageSource: "asset:///images/01.jpg"
	onTouch: {
		nav.count = nav.count + 1;
	}
}

 

Please use plain text.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Problem with slot onTouch in ImageView.

Probably you receive events for touch down and touch up. Try:

 

if (event.touchType == TouchType.Up)
{
  // increment the counter
}

 


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Developer
tanphat1412
Posts: 125
Registered: ‎11-06-2012
My Device: BlackBerry
My Carrier: Mobifone

Re: Problem with slot onTouch in ImageView.

Where I can apply this code, in QML or Qt, I have tried on QML but there is no Touch Up or Down?

Please use plain text.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Problem with slot onTouch in ImageView.

[ Edited ]

Can you try this one please? (in QML)

 

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

Here is a list of all touch events:

 

https://developer.blackberry.com/cascades/reference/bb__cascades__touchevent.html#isdown

 

Q_INVOKABLE functions and slots can be called from QML.


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