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
vingilot
Posts: 224
Registered: ‎03-29-2012
My Device: 9900
My Carrier: Wind

Remove Buttons QML

I use a button but then no longer require it on the screen, what is the best way to delete/remove the butotn from the present screen in QML? If I have missed how to do this in the documentation please point me that way, I want to rely on the documenation as much as possible before coming to the forums, Thanks all.

Please use plain text.
BlackBerry Development Advisor (Retired)
mgoulet
Posts: 329
Registered: ‎05-07-2012
My Device: BB Alpha
My Carrier: N/A

Re: Remove Buttons QML

Hi,

 

You could simply set the visibility off, depending on the use case; What happens once the button dissapears, is there a new page/section on the screen that is shown, or you simply want to remove the ability to interact with the button?

 

Martin

 

Please use plain text.
Trusted Contributor
AllSystemGo
Posts: 140
Registered: ‎11-23-2010
My Device: Torch 9800
My Carrier: Rogers

Re: Remove Buttons QML

You could look into the cookbook sample. In the Button Sample at one point if you press the Eat button the Fruit none disappear : https://github.com/blackberry/Cascades-Samples/blob/master/cascadescookbookqml/assets/Button.qml

Please use plain text.
Developer
vingilot
Posts: 224
Registered: ‎03-29-2012
My Device: 9900
My Carrier: Wind

Re: Remove Buttons QML

My issue is that even when I set the visibility to zero, it is still there, so clicking there would set off the touch events for the button, not whatever might be beneath the button. For more complex UI like this I feel the C++ work might be more appropriate. I am used to the screen setup of the java development and it is more similar. Can anyone confirm that C++ might offer more customization like this?

Please use plain text.
BlackBerry Development Advisor (Retired)
mgoulet
Posts: 329
Registered: ‎05-07-2012
My Device: BB Alpha
My Carrier: N/A

Re: Remove Buttons QML

Have you taken a look a this thread? they are addressing a similar issue with visibility:

 

http://supportforums.blackberry.com/t5/Cascades-Development/Best-Practices-for-Switching-between-Vie...

 

What calls are you makign to make the button invisible?

 

Martin

Please use plain text.
Developer
vingilot
Posts: 224
Registered: ‎03-29-2012
My Device: 9900
My Carrier: Wind

Re: Remove Buttons QML

Thanks I will take a look, I was just setting the opacity to zero really, I haven't considered much else yet.

Please use plain text.
Developer
Zymatic
Posts: 144
Registered: ‎12-18-2010
My Device: Limited Edition Z10 & Blackberry Playbook
My Carrier: Rogers Wireless

Re: Remove Buttons QML

I don't know if you've tried this or not but you could also try setting the button enabled property to false.  That would stop it from being interacted with while the opacity is set to zero.  Depending on your use case this may work.  But if there are other controls behind the button that need to accept touches then this might not help.

 

 

Playbook Apps:
Touch Painter, LinkShrink

BB10 Apps:
NoteToSelf , LinkShrink
Please use plain text.
Developer
vingilot
Posts: 224
Registered: ‎03-29-2012
My Device: 9900
My Carrier: Wind

Re: Remove Buttons QML

[ Edited ]

does that property apply to other controls or just buttons? I have clickable textareas and such as well which that would help with. Additionally, have you used enabled before? I have tried test1.enabled=false; in the javascript as well as enabled:false and they do nothing, the test1.visible=false; works, is enabled different or just not working?

Please use plain text.
BlackBerry Development Advisor (Retired)
mgoulet
Posts: 329
Registered: ‎05-07-2012
My Device: BB Alpha
My Carrier: N/A

Re: Remove Buttons QML

"enabled" is a property of a Control; for more info, see the Cascades API:

https://developer.blackberry.com/cascades/reference/bb__cascades__control.html

 

From this page:

 

bool enabled

Indicates whether the control is enabled.

When a control is disabled, it does not respond to user input. The disabled control continues to receive events, but does not process them. Changing the enabled state may also affect the appearance of the control.

If true the control is enabled, if false it's disabled.

 

Martin

 

Please use plain text.