[SOLVED] Loveframes SetUsable

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
scorpii
Prole
Posts: 9
Joined: Tue Apr 22, 2014 9:29 pm
Location: Sweden

[SOLVED] Loveframes SetUsable

Post 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("")
Last edited by scorpii on Sun May 04, 2014 4:10 pm, edited 1 time in total.
Löve noob
Lua noob
Life noob
User avatar
scorpii
Prole
Posts: 9
Joined: Tue Apr 22, 2014 9:29 pm
Location: Sweden

Re: Loveframes SetUsable

Post 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.
Löve noob
Lua noob
Life noob
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests