TextBounds should work with certain text in the GUI

I have a multi-lined textbox and I want there two be a scrollbar to navigate it. It should have a scrollbar that automatically resizes based on the height of the text. The only way to determine the height of the text is to use TextBounds, but with the following GUI TextBounds is always 0,0

repro.rbxmx (2.1 KB)

For quick reference, this is the text: “ghjghjjjjjjjjj_____________________________________________________________________________________________________________________________________________________________________________________________________________________________”


It seems to be an issue with TextWrapped. You can make the textbox any size, but TextBounds will return (0,0) when ever the text is wrapped onto the next line. It returns correct values with TextWrapped disabled.

RIP – I can’t disable TextWrapped because I need it to be wrapped

Manually wrap it?

Also, does TextFits work?
If it does, you can just keep making the textbox bigger until it fits.

Textbox is already 30,000 px in height so I’ll never need to make it bigger – all I need to do is have the scrollbar auto-resize so you can scroll through the filled space.

.

It’s impossible to work with ROBLOX text boxes. If I change the text while the player is typing it snaps the cursor to the end of the text, so if they’re not typing at the very end of the textbox and they type something that needs to be wrapped, when I go to insert the new line they’ll lose their place and have the cursor snap to the end. This is also true if they backspace through a word or add another before the end of the text – if I need to move around the new lines to wrap it properly, they lose their place even though all they did was backspace through one letter. I think I’ll just disable the visual scrollbar, tell people to use the mousewheel to scroll through the box (people that use laptops / mice without a scrollwheel are SOL), and then tell them to take it up with ROBLOX if they don’t like it for having such crappy textboxes (this bug aside, ROBLOX textboxes are terrible – can’t click to move your cursor, can’t select text, can’t copy out of the textbox, scripters can’t capture focus with the cursor at a specific character (CaptureFocus should take a parameter for which character the cursor should be located at), etc)

I did something similar before.
Have the textbox be invisible (well, the text at least) and “render” the text in a separate TextLabel.

1 Like