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: 144
Registered: ‎12-18-2010
My Device: Limited Edition Z10 & Blackberry Playbook
My Carrier: Rogers Wireless

Custom TitleBar with optional Buttons

Hi,

 

I am currently implement a custom control that I will be using as a title bar. I am doing this so I can have custom colors or background.  I have the basic title bar working fine, with a label that I created a property alias for so I can easily set the title.  

 

My challenge is trying to figure out how to implement optional buttons like the standard BB TitleBar.  Does anyone know how the title bar works when a dismissAction and/or acceptAction are specified?  

 

I would like my custom title bar to look very similiar to the standard TitleBar so that it keeps the BB10 look and feel.

 

Any and all suggestions are greatly appreciated.

 

Thanks,

 

Z

Playbook Apps:
Touch Painter, LinkShrink

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

Re: Custom TitleBar with optional Buttons

[ Edited ]

Within your custom QML or C++ class (you didn't say) you would define two signals one for dismiss and one for accept.

 

Then whenever you use that Custom Control within a QML page you can tie a slot to those signals.

 


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.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Custom TitleBar with optional Buttons

If you are talking about how to hide buttons (again not clear if you are) then you would set a property within your custom QML or C++ class that indicate whether you will be displaying no buttons, the OK button or the Cancel button. How you do that would be up to you but I would probaly use a bit pattern.

 

Then to show/hide the buttons you would just set the visibility based on the bit flags in the property.

 


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.
Developer
Posts: 144
Registered: ‎12-18-2010
My Device: Limited Edition Z10 & Blackberry Playbook
My Carrier: Rogers Wireless

Re: Custom TitleBar with optional Buttons

Sorry for being unclear.  I am doing the control in QML.  My question was in regards to displaying the button.  I am comfortable with how to do the signals and that is not an issue.

 

To be more specific in a standard title bar you do the following:

 

titleBar: TitleBar {
    title: qsTr("TitleBar")
    dismissAction: ActionItem {
        id: dismissAction
        title: qsTr("Cancel")
    }
}

 How does this dismissAction:  part work?  Is this a property that when changed it dynamically creates a Button with the values specified?  I like how the actions are specified and would like to copy this if possible?  I understand it might not be possible with ActionItem but could i do it with Button?  

 

Again sorry if my question is not worded clearly enough.

 

 

Playbook Apps:
Touch Painter, LinkShrink

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

Re: Custom TitleBar with optional Buttons

The truth is we don't know as we have no access to the source, but either creating it dynamically or using the visible property are both valid options.

 

My best guess would be just a property as creating them dynamically in this case is a bit overkill as all that needs to be changed is the visibility and the text.

 


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.