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: 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

So that proves the problem is with your function call not the scope.

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


shreyansjain wrote:

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!


 

By the way you were missing a closing bracket in this snippet of code, hopefully that was just a typo.


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

Thats the issue, I dont think the problem is in the function call either. because if i put a debug line before hiding the importCont again, it prints the debug line. so, ideally, after printing the line, it should change the visibility. 

 

the function call prints to the console and seems to be doing the right thing. 
This is one of the errors where I can't nail down how to debug because i dont see a bug in the onClicked neither in the function call. 

 

And that typo of missing a bracket has no effect on the code as i just wrote it in a hurry to give you a snapshot.

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

Okay, post the code you have so far, and I'll take a look at it when I can.

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

[ Edited ]

One thought I've just had is that you are destroying the pages right and making sure the signal connection is removed, as multiple signal connections could be another possible culprit.

 

I'm pretty sure the problem lies with that function since we've taken it out and proven it's not a scope problem.

 

For me to debug now I would need to see a lot more of your code as you are possibly creating multiple signals that fire off asynchronously and then call an _app function that obviously changes depending on something possibly also mixed up with the signal.

 

Put a few more debug lines in especially in the app call and the signal and make sure they aren't being called multiple times also make sure that that funtion is returing what you expect each time.

 


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

The following is the actual code (with minor edits) and I am not using Qt to create a sheet, so i am assuming signals are handled by QML and subsequently destroyed when closing the sheet.

 

import bb.cascades 1.0
import bb.system 1.0

Page {
    property alias importCont: importCon.visible
    
    titleBar: TitleBar {
        title: "Title Page"
        visibility: ChromeVisibility.Visible
        
        dismissAction: ActionItem {
            title: "Back"
            onTriggered: {
                sheet.close();
            }
        }
    }
    
    Container {
        background: back.imagePaint
        attachedObjects: [
            ImagePaintDefinition {
                id: back
                repeatPattern: RepeatPattern.XY
                imageSource: "asset:///In-App_icons/background/backG.amd"
            }
        ] // end of attachedObjects
        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: "Importing ..."
                            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
                        }                        
                    }
                }
                
                Label {
                    text: "Label Text"
                    multiline: true
                    bottomMargin: 0
                    textStyle {
                        color: Color.White
                        fontSize: FontSize.Medium
                        fontWeight: FontWeight.W500
                    }
                }
                TextArea {
                    id: financeTextArea
                    preferredHeight: 250
                }
                
                Button {
                    id: importFinance
                    horizontalAlignment: HorizontalAlignment.Center
                    text: "Import"
                    
                    onClicked: {
                        console.log("Enabiling the importing Text");
                        importCont = true;
                        
                        if(financeTextArea.text.length > 0){
                            if(_app.doSomething(financeTextArea.text)){
                                _app.toastAlert("Succesfully Done Something@");
                                console.log("Disabling the importing Text");
                                importCont = false;
                                sheet.close();                              
                            }
                            else {
                                _app.toastAlert("Error: xxxx");
                                console.log("Disabling the importing Text");
                                importCont = false;
                                sheet.close();                              
                            }
                        }
                        else {
                            _app.toastAlert("Please Enter the text");
                            console.log("Disabling the importing Text");
                            importCont = false;
                            sheet.close();                              
                        }

                    }
                }
               
            }
        }
    }
}

 

Waiting for your reply Smiley Happy

 

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

Okay it's coming up to midnight here so I'll plug it in and take a look at it tomorrow if someone hasn't spotted the problem overnight.


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

[ Edited ]

As promised I've plugged this in and for me at least it seems to be working as programmed.

 

Are you expecting the Importing text to display and then dissapear?

If so then the time between the calls is not sufficient to do this, you would need to put in a delay or ensure that your function call takes a significant amount of time and that your call is asynchronous.

 

Perhaps that is what you were trying to do with the signals code?

 

There's not a lot more I can do without access to your full code, try putting back in the signal slot mechanism and then making the function call asynchronous as I believe this is what you are trying to do.

 

[Edit] You can prove the code works by setting the initial visibility of the container to true.


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

Thank you very much for your help!
I had to release an update soon and i decided to release without fixing this issue. 

 

I will update this code with signals/slots to make it work!

 

Thanks again!

 

S.