StablexUI icon indicating copy to clipboard operation
StablexUI copied to clipboard

Calculating size needed for text

Open RudolfVonKrugstein opened this issue 10 years ago • 4 comments

Hey,

I have a text widget embeded in a floating widget I want to display as an overlay over everything else. How want the size of the widgets to be such that the complete text can be displayed at once, but the widgets are no bigger than needed for that.

The text is not displayed completly when the widgets appear, but is gradually added later. But it is know beforehand what the complete text will be.

Can I somehow calculate the size (assuming for example a given width) the widget will need and set it correctly?

Thanks! Nathan

RudolfVonKrugstein avatar Jul 29 '14 20:07 RudolfVonKrugstein

Actually Floating widget should automatically adjust to size of content. Can you show your code?

RealyUniqueName avatar Jul 30 '14 16:07 RealyUniqueName

Hey,

In pseudo code, this is what I want to do:

var textDisplay = UIBuilder.buildFn('gui/textDisplay.xml');
var text = UIBuilder.getAs(Text, "text");
haxe.Timer.delay(text.text += "Hello", 100);
haxe.Timer.delay(text.text += "World", 200);
(...)

the text display is a "Text" widget contained in a "VBox". The "VBox" grows as text is added, but I want it to have full size from the beginning...

RudolfVonKrugstein avatar Aug 03 '14 18:08 RudolfVonKrugstein

Now i got it ) You cant create text field with full text initially and after creation set it to blank string.

RealyUniqueName avatar Aug 03 '14 18:08 RealyUniqueName

mmh, that does not seem to work. At what point is the containing widget resized? And isn't it re-resized when I set the text to blank?

RudolfVonKrugstein avatar Aug 04 '14 10:08 RudolfVonKrugstein