Change behaviour for text-overflow Property in TextBoxes

I’m trying to achieve the default behaviour for input fields in HTML for Roblox Textboxes.

When a user types past the textbox boundaries, it should show new characters instead and clip the old ones to the left. Right now it clips text from the right, which makes it looks like the textbox is not accepting any new input when overflown.

I had no luck messing with the existing properties. If it’s already possible I’d be greatful if somebody could tell me how. With scripts I guess I could check if the TextBounds are past Size, and if so, switch to TextAlign: Right? But seems hacky for something that I believe should be the default behaviour for single-line textboxes.

2 Likes

Try using this 3-liner inside of your TextBox:

script.Parent:GetPropertyChangedSignal("Text"):connect(function()
	script.Parent.TextXAlignment = script.Parent.TextFits and Enum.TextXAlignment.Left or Enum.TextXAlignment.Right
end)

Ah, seems like you had already thought of that - yes, TextBoxes are really limited to what you can currently do, in terms of more powerful functionality like caret and selection control, padding etc.

As for it being default behavior, that seems like a good idea - users can then see what they’re typing, instead of guessing that they got all keypresses done right. :frowning:

2 Likes

I’ll try to change this when I have time. Using text alignment isn’t a good solution in the case of multi-line textboxes. Right now, the best solution in that case would be to put the textbox inside of a frame that clips, and then move the textbox horizontally so the cursor is always visible.

5 Likes

Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.