Search code examples
c++blackberry-10blackberry-cascades

Create a button on Cascades with background image, BB-10


I want to create a button using Cascades on Black Berry 10 development which has an image as a background and also possibly a text with white color. I found this class button, but it seems to not support setting an image as a background on the button. What can I do? What are the alternate ways? Maybe I should consider another library than Cascades for creating my UI??? any suggestions?


Solution

  •  Container {
            id:account
            signal buttonClicked()
            layout: DockLayout {
            }
            preferredWidth: 768.0
            topMargin: 40.0
            bottomMargin: 40.0
            ImageButton {
                id: addButton
                defaultImageSource: "image/button_normal.png"
                pressedImageSource: "image/button_press.png"
                horizontalAlignment: HorizontalAlignment.Center
                onClicked: {
                   buttonClicked();
                }
            }
            Label {
                text: "Add"
                verticalAlignment: VerticalAlignment.Center
                horizontalAlignment: HorizontalAlignment.Center
                textStyle {
                    base: SystemDefaults.TextStyles.BodyText
                    fontSize: FontSize.Small
                    color: Color.create("#ffffff")
                }
                touchPropagationMode: TouchPropagationMode.None
            }
        }