Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I automatically scale a textbox?

Asked by
Fifkee 2017 Community Moderator Moderation Voter
5 years ago

Alright, lets say I have a TextBox. And, if I type so much to the point where the text wraps, I made the decision to extend the textbox by double it's TextBounds.Y, which is about 28.

I was going to do this by checking the TextBounds to see if it excels 28, which then I'd just multiply the AbsolutePosition.Y by the amount of times 28 goes into the TextBounds.Y, and plug it into the Offset UDim2.

But, the issue falls here: The TextBounds does not change if the text is wrapped. And now, I'm stumped. What do I do?

Second (and last attempt) (i have no idea where the first attempt went but its somewhere)

game:GetService('RunService').RenderStepped:Connect(function(step) --I'll change this to .Changed later, ignore ty (i mean the thingy that does the thing where it only looks for one property changed but idk the name so i just say changed ty)
    if (script.Parent.TextBounds.X > math.floor(script.Parent.AbsoluteSize.X-8)) then
        script.Parent.Size = UDim2.new(0.476,0,0.061,script.Parent.Size.Y.Offset+49.654)
    else
        script.Parent.Size = UDim2.new(0.476,0,0.061,0);
    end
end)

thanks!

(if this question was answered please link me, maybe I was being too specific by searching the word "textbox" but ._.)

Answer this question