Nick
07/08/2023, 1:42 AMHeight
) anywhere. happy to review any minimum repro you have if you think it’s a bug though.ayodele
07/08/2023, 3:15 PMfitText
wrapsWords
is true. So if wrap words is false, the width is returned.val text = Label("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.").apply {
foregroundColor = Red
wrapsWords = true
}
display += text
display.layout = Layout.simpleLayout {
var y = 0.0
it.children.forEach { view ->
view.bounds = Rectangle(0.0,y, view.width, view.height)
y += view.height
}
}
Nick
07/08/2023, 4:32 PMLabel
figures out it’s size by calling measureText
on its `behavior`; the behavior honors fitText
and tells the label what size to take based on that, the text, and wrapping. so you need a behavior
installed for any of this to work. the default logic is to set the size to that of the text when there is no wrapping. you can see how CommonLabelBehavior
handles measureText.
with wrapText = true
, there needs to be some width to wrap at, so TextMetrics.size
(used for all text measurement) requires a width to determine the text height when it is wrapped at that width. otherwise there’s no way to say how much space the text takes up, other than what its size would be if it were on a single line (i.e. no wrapping). so the label NEEDS a width
specified to correctly measure its height when wrapping is enabled. you also need to keep Width
within fitText
so the label retains that size of course; but that’s the default behavior if you don’t change fitText
.
let me know if that clarifies things and if this is the behavior you’re seeing.ayodele
07/08/2023, 4:48 PM