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
jan_macura
Posts: 20
Registered: ‎08-02-2012
My Device: -
My Carrier: SW Developer

Label elide and wrapping

Hi,

 

elide is working when Label's preferredWidth is set. How can the preferredWidth property be set from the parent, so I do not have to count it manually? Have a look at my following Container

 

Container {
layout: DockLayout {
}
layoutProperties: DockLayoutProperties {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Bottom
}
background: Color.create(0, 0, 0, 0.5)
Container {
layout: StackLayout {
leftPadding: 20
rightPadding: 20
bottomPadding: 10
topPadding: 10
}
layoutProperties: DockLayoutProperties {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Center
}
Label {
text: "asf asdf asdfasjd hfkjladshf asdlkjfjklasdhf kjlsadhfasdja sdfas fads fasd fasd"
textStyle.base: SystemDefaults.TextStyles.TitleText
textStyle.color: Color.White
preferredWidth: ????
}
Label {
text: "asf asdf asdfasjd hfkjladshf asdlkjfjklasdhf kjlsadhfasdj asdfads fasdf ads sfda"
textStyle.base: SystemDefaults.TextStyles.SubtitleText
textStyle.color: Color.White

preferredWidth: ????
}
}
}

 

When the wrapping of Label will be supported?

 

Thanks,

Jan

 

Please use plain text.
BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: Label elide and wrapping

Playing with HelloCascades, here's what I observe in Beta2:

 

Changed Label to:

text: qsTr("Hello World here's a song that we're singing. Come on get happy!")

 

1. preferredWidth: 550 within Label:

    ==> Hello World...

 

2. maxWidth: 550 within Label:

    ==> Hello World here's a song t

    (clipped by window)

 

3.preferredWidth: 550 within container:

    ==> Hello World here's

 

4. maxWidth:550 within container:

    ==> Hello World here's

 

I'll check into this further, but it looks like you'll need to set the preferred width of each affected Label on a case by case basis.  This may be where you ultimately want to control this anyway.

 

As for roadmap: unfortunately I do not have information regarding future features in the upcoming NDK releases. This is normally done through the offical RIM channels.
Please monitor official RIM developer channels for announcements related to upcoming releases.
The main developer page https://developer.blackberry.com/
and the twitter feed: http://twitter.com/BlackBerryDev
are two good places to monitor for new information.

 

Stuart

Please use plain text.
BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: Label elide and wrapping

Please use plain text.
Developer
jan_macura
Posts: 20
Registered: ‎08-02-2012
My Device: -
My Carrier: SW Developer

Re: Label elide and wrapping

how can the preferredWith of Label be set from the parent container actual width?

 

thanks,

Jan

Please use plain text.
BlackBerry Development Advisor (Retired)
amarcon
Posts: 155
Registered: ‎07-16-2012
My Device: Dev Alpha
My Carrier: Bell

Re: Label elide and wrapping

Perhaps if you set an id for you Container and also set its preferredWidth, then you can use its value within your label or other components such as preferredWidth: containerId.preferredWidth

 

Based on the sample you've provided, would be something like this:

 

Container {
        layout: DockLayout {
        }
        layoutProperties: DockLayoutProperties {
            horizontalAlignment: HorizontalAlignment.Fill
            verticalAlignment: VerticalAlignment.Bottom
        }
        background: Color.create(0, 0, 0, 0.5)
        Container {
            id: checkContainer
            layout: StackLayout {
                leftPadding: 20
                rightPadding: 20
                bottomPadding: 10
                topPadding: 10
            }
            layoutProperties: DockLayoutProperties {
                horizontalAlignment: HorizontalAlignment.Fill
                verticalAlignment: VerticalAlignment.Center
            }
            preferredWidth: 550.0
            Label {
                text: "asf asdf asdfasjd hfkjladshf asdlkjfjklasdhf kjlsadhfasdja sdfas fads fasd fasd"
                textStyle.base: SystemDefaults.TextStyles.TitleText
                textStyle.color: Color.White
                preferredWidth: checkContainer.preferredWidth
            }
            Label {
                text: "asf asdf asdfasjd hfkjladshf asdlkjfjklasdhf kjlsadhfasdj asdfads fasdf ads sfda"
                textStyle.base: SystemDefaults.TextStyles.SubtitleText
                textStyle.color: Color.White
                preferredWidth: checkContainer.preferredWidth
            }
        }
    }

 Hope this helps.

Please use plain text.
Developer
jan_macura
Posts: 20
Registered: ‎08-02-2012
My Device: -
My Carrier: SW Developer

Re: Label elide and wrapping

Thanks for this, but I want to avoid manual setting of component width, since I want my app to support landscape and portrait mode and use as much width as possible. I was used to use parent width from native QML. Is something like this possible in cascades?

 

Jan

Please use plain text.
BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: Label elide and wrapping

I assume you've read https://developer.blackberry.com/cascades/documentation/dev/orientation/index.html

 

The whole point of layouts is so that items are given an appropriate size based on the needs of different components. Depending on the orientation you may want a different layout, or you might just want the layout rules applied.

 

In Beta1 we had to hardcode a number of sizes that we clearly do not want to hardcode.

Now that we have orientation things should start being cleaner.

 

I'm unclear about your question: are you encountering additional difficulties, or are you merely trying to work around the issues already reported against the layout of Labels?   There is a way to be told the size of a container, but this is not the recommended choice, and is likely not the solution you want long term.

 

Stuart

Please use plain text.