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
Trusted Contributor
itcraps
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10
Accepted Solution

Using ImageView as a Button

any idea how to achieve this? thanks

www.jackdevora.com
Super Contributor
Meghasanghvi
Posts: 306
Registered: ‎08-10-2010
My Device: Not Specified

Re: Using ImageView as a Button

Hi,

You can check the sample from the github and project name is CascadeCookBookqml.

 

Link: https://github.com/blackberry/Cascades-Samples

 

In the Assets folder button.qml contain the ImageButton Demo you can refer that.

 

 

Thanks,

Megha.

 feel free to accept as a solution or like the post.

 

 

Regular Contributor
_NishantShah
Posts: 76
Registered: ‎07-31-2012
My Device: Blackberry

Re: Using ImageView as a Button

[ Edited ]

Hi itcraps,

 

You can use onTouch slot to do so.

 

onTouch :

{

if(event.touchType == TouchType.Up)

     doYourStuffHere();

}

 

You may use other TouchType too.

 

Regards,
Nishant Shah

Regular Contributor
Megha_9_dec
Posts: 56
Registered: ‎08-21-2012
My Device: BB10

Re: Using ImageView as a Button

Hi itscrap,


You can use ImageButton in this case. Provide defaultImageSource to it. & in its onClicked event you can handle its tap just like in Button.

 

ImageButton {
defaultImageSource: "asset:///myDefaultImage.png"
pressedImageSource: "asset:///myPressedImage.png"
disabledImageSource: "asset:///myDisabledImage.png"
onClicked: {
\\ your stuffs
}

}

 

you can refer this link: https://developer.blackberry.com/cascades/reference/bb__cascades__ImageButton.html

Trusted Contributor
itcraps
Posts: 238
Registered: ‎12-26-2010
My Device: BlackBerry Z10

Re: Using ImageView as a Button

thanks Meghas :smileyhappy:

www.jackdevora.com