I have a problem on the textbox. Which it automatically inserts a carriage return "\r"
or "\13"
.
I believe you can see it as a second space.
As seen on the output.
Script:
local textbox = script.Parent
textbox.Text = "$ "
--local previoustext = textbox.Text
textbox.FocusLost:Connect(function(e)
textbox.Interactable = false
if not e then
textbox.Interactable = true
return
end
local txt = textbox.Text
textbox.Text ..= "\n$ "
print(txt:byte(1, #txt))
textbox:CaptureFocus()
--previoustext = textbox.Text
textbox.Interactable = true
end)
More details:
Font: Roboto Mono
1 Like
Tried using :sub(1, #text - 1)
on the textbox.Text
but the carriage return still there.
1 Like
GTX_3
(GTX_3)
July 26, 2024, 3:09pm
#3
local textbox = script.Parent
textbox.Text = "$ "
textbox.FocusLost:Connect(function(enterPressed)
textbox.Interactable = false
if not enterPressed then
textbox.Interactable = true
return
end
local txt = textbox.Text
txt = txt:gsub("[\r\n]+", "")
textbox.Text = txt .. "\n$ "
for i = 1, #txt do
print(txt:byte(i))
end
textbox:CaptureFocus()
textbox.Interactable = true
end)
1 Like
It didn’t work unfortunately.
Keystrokes:
h i [Enter] h e l l o [Enter]
textbox.Text:
bytes: 36 32 104 105 36 32 104 101 108 108 111 10 36 32 13
"$ hi$ hello\n$ \r"
1 Like
It seems that when I press enter it inserts a carriage return.
So I added a little task.wait()
and it work’d.
local textbox = script.Parent
textbox.Text = "$ "
textbox.FocusLost:Connect(function(enterPressed)
textbox.Interactable = false
if not enterPressed then
textbox.Interactable = true
return
end
textbox.Text ..= "\n$ "
task.wait() -- wait before capture focus
textbox:CaptureFocus()
textbox.Interactable = true
end)
It seems that the Enter and CaptureFocus collision inserts a carriage return on the textbox
system
(system)
Closed
August 9, 2024, 3:37pm
#6
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.