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: 587
Registered: ‎04-01-2009
My Device: Z10, PlayBook
My Carrier: NA

Hiding custom controls

I have a cutsom control that I want to hide.

 

From JavaScript code, I call:

 

myCustomControl.visible = false;

 

... but the control doesn't get hidden.

 

Is this because I need to individually hide each of the sub-controls that make up my custom control?  I am surprised that this doesn't "just work".

Developer
Posts: 587
Registered: ‎04-01-2009
My Device: Z10, PlayBook
My Carrier: NA

Re: Hiding custom controls

Maybe that's not the problem...

 

It would appear that the JavaScript function in my custom control isn't even being called so I'll need to figure out why.

Developer
Posts: 587
Registered: ‎04-01-2009
My Device: Z10, PlayBook
My Carrier: NA

Re: Hiding custom controls

The issue was that I also needed to connect up the signal to my handler:

 

model.name1Changed.connect(ratingControl1.onName1Changed);

 

Note that the example:

 

https://developer.blackberry.com/cascades/documentation/ui/integrating_cpp_qml/index.html

 

... somewhat bizarrely sets up this connection in an onClick handler:

 

    onClicked: {

        cppObject.valueChanged.connect
                (increaseButton.onCppValueChanged);
        cppObject.value = cppObject.value + 1;
    }
Not sure why this would be exemplified that way. I used the "onCreationCompleted" event of my custom control as a place to call the "connect", although I'm not sure what the best solution is in general for doing that.
Retired
Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: Hiding custom controls

Sounds like you addressed everything except for being puzzled over where a connect was done in a sample app.

 

In general, I would expect the connects to be done where you suggest, in onCreationComplete.

Some apps may have good reasons to do it elsewhere:

- if the object handling the message is dynamically created only as needed.   The connect has to wait until then

- some behaviour is turned on or off, and connect is used to manage this

- the code needs to be developed quickly and the other spot is easier

- the code is for demonstration purposes and the connect is incidental; adding the best handler may add noise to what is being demonstrated.

 

One could quibble with my last point, perhaps.

I agree that onCreationComplete would be my default choice.  (Actually, I tend to use C++ more and tend to have my connects and handlers in C++)

 

Were you just musing, or do you think the sample app is misleading and should be adjusted?   If the sample is in git-hub you should be able to make some corrections to a clone and issue a pull request.

 

Stuart

Developer
Posts: 587
Registered: ‎04-01-2009
My Device: Z10, PlayBook
My Carrier: NA

Re: Hiding custom controls

Sorry for the delayed response.

 

I do think it would be worth adjusting the sample code if that seems reasonable.