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
Posts: 146
Registered: ‎07-03-2013
My Device: BB 9360
My Carrier: WIND

onClick signal not hiding container in a sheet

Hello,

So, I have a page and the user clicks on that page, a sheet is popped-up. 

I have a container which is hidden (visible: false) and a button in different container and the onClicked signal of that button, the container needs to change its visibility (visible: true). 
For some weird reasons, console.log(..) works and tracing the code seems shows it is suppose to change the visibility but its not doing it. 

Have debugged it enough and seriously I cannot figure out whats wrong? i have done similar things on my other pages and it just works. (for other pages, i used onTouch rather than onClick since i have no button but visibilty of container works)

the following is a snippet of my code.

 

//Sheet Code
// rough code, but i hope you get the idea

Page {
    // main container
   Container {
    // Container {
          id: cont1
          visible: false
..... } Container {
id: cont2 Button { id: testButton onClicked: { cont1.visible = true; // returns true // takes few seconds to return if(_app.functionTrue()){ cont1.visible = false; sheet.close(); } } ] } } }

 

Thanks!

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: onClick signal not hiding container in a sheet

Do you get any errors in the log?

 

It's possible that in your actual code it's mispelled or more likely out of scope.

 

Try setting the visibility property as a property alias in the top container first of all, (and assuming that works) work back from there.

 

If the property alias doesn't work please post your actual code.

 


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

Developer of stokLocker, Sympatico and Super Sentences.
Highlighted
Developer
Posts: 146
Registered: ‎07-03-2013
My Device: BB 9360
My Carrier: WIND

Re: onClick signal not hiding container in a sheet

I have debugged it enough and very certain code is correct. Maybe scope could be an issue.
I totally forgot about the property alias.
I will try soon and share soon the results.

Thanks
Developer
Posts: 146
Registered: ‎07-03-2013
My Device: BB 9360
My Carrier: WIND

Re: onClick signal not hiding container in a sheet

Property alias didnt work. 

Posting the code for Sheet

 

import bb.cascades 1.0
import bb.system 1.0

Page {
    property alias importCont: importCon.visible
    
    titleBar: TitleBar {
        title: "Page Title"
        visibility: ChromeVisibility.Visible
        
        dismissAction: ActionItem {
            title: "Back"
            onTriggered: {
                sheet.close();
            }
        }
    }
    
    Container {
        ScrollView {
            Container {
                rightPadding: 10
                leftPadding: 10
                
                Container {
                    id: importCon
                    rightPadding: 10
                    leftPadding: 10
                    topPadding: 10
                    visible: false

                    Container {
                        layout: StackLayout {
                            orientation: LayoutOrientation.LeftToRight
                        }
                        Label {
                            id: importingLabel
                            text: "Label Text ..."
                            textStyle {
                                color: Color.Yellow
                                fontSize: FontSize.Medium
                                fontWeight: FontWeight.W500
                            }
                            layoutProperties: StackLayoutProperties {
                                spaceQuota: 1
                            }
                        }
                        ActivityIndicator {
                            id: activityInd
                            scaleX: 1.0
                            scaleY: 1.0
                            running: true
                        }                        
                    } // end of importCon container
                } 
                                
                Button {
                    id: importFinance
                    horizontalAlignment: HorizontalAlignment.Center
                    text: "Click Me"
                    signal importClicked
                    
                    function signalFunction(){
                          if(_app.returnTrue()){
                                importCont.visible = false;
                                sheet.close();                              
                            }
                            else {
                                importCont.visible = false;
                                sheet.close();                              
                            }
                    }
                    
                    onClicked: {
                        importCont.visible = true;
                             importFinance.importClicked.connect(importFinance.signalFunction());
                        importFinance.importClicked();
                    }
                } // end of button
            }
        }
    }
}

 

Hope That Helps!

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: onClick signal not hiding container in a sheet

[ Edited ]

Well it wouldn't be importCont.visible = false for a start as you have aliased the importCont.visible, it would just be importCont = false; or importCont = true; as appropriate.

 

What you've put is akin to saying importCon.visible.visible = false; which obviously won't work.

 

I've also never put a function within a Button before which might/might not be relevant I try and restrict them to the top container.

 

Any way try and fix all the importCont lines, have another go and if it doesn't work I'll put it in a test app.


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 146
Registered: ‎07-03-2013
My Device: BB 9360
My Carrier: WIND

Re: onClick signal not hiding container in a sheet

Hello, 

For my other QML pages, I have used property alias that way only and it worked. 

But I still replaced the "importCont.visible = true" to "importCont = visible" and it still DOESNT work. 

 

I didnt have the function with in a component as well but needed to check if the onClicked signal of Button was working. And it surely works. Anyways, i have removed the function call and instead put all the code with in the onClicked singnal.

onClicked: {
  importCont = true;

  if(_app.returnTrue(){
    importCont = false;
  }
}

 

 

Does that help?

 

Thanks again!

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: onClick signal not hiding container in a sheet

How about taking out the returnTrue function call (strange name by the way) and just seeing if clicking the button works, sorry just want to rule out a function I can't see the code for.

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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: onClick signal not hiding container in a sheet

Can you then post the code you have so far to save me some typing, thanks.

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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 146
Registered: ‎07-03-2013
My Device: BB 9360
My Carrier: WIND

Re: onClick signal not hiding container in a sheet

Yes, That works if I take the function out (btw, returnTrue() is not the original name of the function, the point is there is a function that gets invoked and returns a boolean value and based on that value, show/hide the importCont.

 

The chronological event is something like:
1) Show the sheet page and render everything (button,labels etc) except (importCont container)
2) user clicks button and in the onCLicked signal, render the importCont container to let users know some processing is going on. the processing is the function which gets invoked and based on that function show/hide the importCont container and subsequently close the sheetPage().

 

Do you still want to see the code?

 

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: onClick signal not hiding container in a sheet

LOL, not if it works! :-)

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

Developer of stokLocker, Sympatico and Super Sentences.