Text(Button/Box/Label).TextBounds to be set upon parent

Its a bit annoying that whenever I want to view a Text(Button/Box/Label).TextBounds property I first must parent it to a screengui and wait a frame before the TextBounds property shows a the actual X/Y and not 0,0… Unless there’s a reason why for the current behavior to act the way it does, if there is one then I would like to hear it.

1 Like

The text isn’t rendered until after the current frame ends, this means that the text bounds won’t have been calculated until the next frame.

Been a few years ago, but I want to express how still frustrating it is trying to get TextBounds after setting Text I have no idea when a frame ends, I couldn’t even use RunService:Stepped on the server to wait for it without having to use loops (which are inefficient in my case). We can always use this but then what’s the point of TextBounds in the first place for text objects?

And… using wait? Blegh.

TextBounds should definitely update immediately after Text is set; make setting Text a synchronous thing so TextBounds is ready to be referenced right after.

With the release of quantum gui, the TextBounds property updates immediately (well, as soon as you read it, if I’m not misunderstanding :slight_smile:). Running this in studio:

local sg = Instance.new("ScreenGui")
sg.Parent = game:GetService("CoreGui")
local label = Instance.new("TextLabel", sg)
label.Text = "Test"
print(label.TextBounds)
label.Text = "Test Test"
print(label.TextBounds)
wait(1)
print(label.TextBounds)

prints:

22, 12
47, 12 (x2)
2 Likes