When the amount of text exceeds the TextBox’s width, the TextBox’s view area snaps back to the beginning when you scroll to the end then unfocus the TextBox. I want it so if you leave the TextBox’s CursorPosition at any position and unfocus the TextBox the TextBox’s view area stays at that position.
I tried doing what I wanted by placing a TextBox inside a ScrollFrame and having the TextBox’s AutomaticSize = X and the ScrollFrame’s AutomaticCanvasSize = X. I then use the following code to “push” the ScrollFrame’s X-Offset CanvasPosition so it mimics what the normal TextBox does.
local OldAbsoluteCanvasSize = 0
ScrollFrame:GetPropertyChangedSignal("AbsoluteCanvasSize"):Connect(function()
local NewAbsoluteCanvasSize = ScrollFrame.AbsoluteCanvasSize.X
if NewAbsoluteCanvasSize - ScrollFrame.AbsoluteSize.X <= 0 then
return
end
ScrollFrame.CanvasPosition = Vector2.new(ScrollFrame.CanvasPosition.X+(NewAbsoluteCanvasSize-OldAbsoluteCanvasSize))
OldAbsoluteCanvasSize = NewAbsoluteCanvasSize
end)
However, it only mimics the normal TextBox if I type new letters at the end and fails everywhere else. Does anyone know how to disable or work-around this behaviour?