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
babakar
Posts: 751
Registered: ‎05-29-2012
My Device: see later
Accepted Solution

imagebutton click

 ImageButton
                        {
                            
                            defaultImageSource:  "asset:///images/ic_user.png"
                            pressedImageSource:  "asset:///images/ic_user.png"
                            disabledImageSource:  "asset:///images/ic_user.png"
                            preferredHeight: 210
                            preferredWidth: 210
                           
                            // text: "Login"
                        }

 

 

how can i fire click option? call myapp.vclickjbutton(); from c++side

 

Please use plain text.
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: imagebutton click

Can you explain your problem a bit more.

If you are asking how to programatically click the button then this is not possible.

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
babakar
Posts: 751
Registered: ‎05-29-2012
My Device: see later

Re: imagebutton click

well if the user clicks on that imagebutton...i cannot fire an event from my c++ code? like i do on normal button?

onClicked: {

quoteApp2.clickedButton();
}


so imagebutton is not same as button?
Please use plain text.
Developer
babakar
Posts: 751
Registered: ‎05-29-2012
My Device: see later

Re: imagebutton click

aha it works

 

 

but let me show u what am trying to do , and not working

 

I have container with height 210...inside it imagebutton + text.

 

am trying to create an imagebutton with height/width 210..and opacxity 0...on click of any place of the container i call the imagebutton click

 

 

 

1 -  i tried imagebutton inside container, u click imagebutton

2 - imagebutton with no container

3 - container with gestures

 

so am trying to work this way too.. where i have imagebutton with opacity 0..and trick the user as if clicking on container..instead clicking on imagebutton

 

 

 Container {
                    leftMargin: 15.0
                    rightMargin: 15.0
                    background: Color.DarkGray
                    layoutProperties: StackLayoutProperties { spaceQuota: 1.0 } 
                    Container {
                        background: Color.DarkGray
                        preferredHeight: 210
                        preferredWidth: 210
                        ImageButton 
                        {
                            onClicked: {
                                
                                quoteApp2.clickedButton();
                            }
                            
                            defaultImageSource:  "asset:///images/ic_user.png"
                            pressedImageSource:  "asset:///images/ic_user.png"
                            disabledImageSource:  "asset:///images/ic_user.png"
                            preferredHeight: 210
                            preferredWidth: 210
                            opacity: 1
                            
                            // text: "Login"
                        }
                        layout: DockLayout {}
                        Container{
                            layout: StackLayout
                            {
                                orientation: orientation.TopToBottom
                            }
                            horizontalAlignment: HorizontalAlignment.Center
                            verticalAlignment: VerticalAlignment.Center
                            
                            ImageButton 
                            {
                                horizontalAlignment: HorizontalAlignment.Center
                                verticalAlignment: VerticalAlignment.Center
                                defaultImageSource:  "asset:///images/ic_phone.png"
                                pressedImageSource:  "asset:///images/ic_phone.png"
                                disabledImageSource:  "asset:///images/ic_phone.png"
                                preferredHeight: 96
                                preferredWidth: 96
                                // text: "Login"
                            }
                            Label {
                                text: "Contact us"
                                textStyle {
                                    base: SystemDefaults.TextStyles.SubtitleText
                                    textAlign: TextAlign.Center
                                    color: Color.Black
                                }
                            }
                        
                        }
                    }

 

Please use plain text.
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: imagebutton click

Take a look at touch propagation for ways to do this without resorting to code that needs programmatic control of UI elements...

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

If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
babakar
Posts: 751
Registered: ‎05-29-2012
My Device: see later

Re: imagebutton click

it works, if i change the order..
and put my fake imagebutton below the container which has imagebutton + text

so i now covered the 4 ways. thanks alot. will show them to my boss to decide so


1 - have a container, inside it image button..u click imaebutton goes to new page.but not click on all of container
2 - gesture onlongpressed for entire container
3 - no containers, just design me an entire imagebutton
4 - fake imagebutton with opacity 0..covering entire container.on click of any palce on container i go to function clickedbutton.
Please use plain text.
Developer
babakar
Posts: 751
Registered: ‎05-29-2012
My Device: see later

Re: imagebutton click

worth to note, noticed on opacity 0 no imagebutton click fired..but opacity 1 fired.

another point of discussion
Please use plain text.
Developer
slashkyle
Posts: 820
Registered: ‎10-16-2012
My Device: Red Z10

Re: imagebutton click

[ Edited ]

you can have a container that is whatever size you desire wtih a transparent background.  subscribe to touch events and it will function essentially as a button

 

Container {
     id: mButton
minWidth: 720
minHeight: 210 onTouch: { if (event.isDown()){ //This is where you would visually adjust for a visible component } else if (event.isUP()){ // This is where you would likely want to use as your onClicked signal //Revert visual changes } else if (event.isCancel(){ // Revert visual changes } } }

 Also if you set something above this and set the opacity to 0, I do not belive the touch will pass through unless you turn the touchPropagationMode to none or set the comopnent visibility to false

Please use plain text.