Page 1 of 1

[SOLVED] Loveframes SetUsable

Posted: Sat May 03, 2014 4:14 pm
by scorpii
Hi,
I'm using the awesome loveframes lib and am trying to restrict the user from entering anything but numbers in a textinput object.

So I've tried:

Code: Select all

local textinput = loveframes.Create("textinput")
textinput:SetUsable({"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"})
But still it was possible to insert tab characters. So then I tried to set the tab character as unusable:

Code: Select all

local textinput = loveframes.Create("textinput")
textinput:SetUsable({"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"})
textinput:SetUnusable({"\t"})
That didn't help either. It was still possible to insert tab characters. Does anyone know how to do this?


Solution proposed by Nikolai Resokav:

Code: Select all

textinput:SetTabReplacement("")

Re: Loveframes SetUsable

Posted: Sat May 03, 2014 4:57 pm
by scorpii
As a workaround I'm currently doing:

Code: Select all

textinput.OnTextChanged = textChanged
-snip-
function textChanged(obj, text)
    obj:SetText(obj:GetText():gsub("%s+", ""))
end
It feels a bit cumbersome though.