Noteworthy work-around for bugged labels

Started by Sebastian, May 06, 2022, 06:13 PM

Previous topic - Next topic

Sebastian

Original discord conversation

PS: Be aware that this fix is a pretty new find, so there can be side-effects.
Didn't yet face anything, but still..



Labels tend to be very buggy sometimes, especially when using different constructors.
(@NewK knows better)

Out of all constructors
Quote from: wikiGUILabel

1. Constructor GUILabel()

2. Constructor GUILabel(position, colour)
Parameter types: VectorScreen, Colour

3. Constructor GUILabel(position, colour, text)
Parameter types: VectorScreen, Colour, string

4. Constructor GUILabel(position, colour, text, flags)
Parameter types: VectorScreen, Colour, string, int

seems that the 4th one works the best. (DecUI is using it too, in it's best way)
Using any other one will lead to weird and obscure behaviour.

Still, here is something that might fix this ^ and can be found here v
label.Size = VectorScreen(0,0);
label.TextPaddingTop = 0; // or Right, or Left, or Bottom, as any of them seem to do the thing
[spoiler=all TextPadding functions]
   label.TextPaddingTop = 0;
   label.TextPaddingBottom = 0;
   label.TextPaddingLeft = 0;
   label.TextPaddingRight = 0;
[/spoiler]

Just apply these settings once you are done with your label. (so, at the end of it)

[spoiler="in case of using DecUI"]
NewK — 04/26/2022
you can use the postConstruct function which will be called after an element is built

"this" in that case is the GUILabel
[/spoiler]



Some bugs that can happen when using other constructors than the (4th) one with 4 arguments.

1. Label might not show up at all, when the text is not long/strong/heavy enough, or has some flags.


2. Labels placed in column might be pushed more to the right