41 lines
1.2 KiB
Lua
41 lines
1.2 KiB
Lua
keyvalues="000abcdefghijklmnopqrstuvwxyz1234567890"
|
|
textbox={
|
|
value=nil,
|
|
title=nil,
|
|
old_update=nil,
|
|
return_function=nil,
|
|
|
|
show=function(title, retfun, default_value)
|
|
textbox.title=title
|
|
textbox.value=default_value
|
|
textbox.old_update=update
|
|
update=textbox.update
|
|
textbox.return_function=retfun
|
|
if textbox.value==nil then textbox.value="" end
|
|
end,
|
|
|
|
update=function()
|
|
rectfill(20,50, 140, 90,6)
|
|
rect(20,50, 140, 90,8)
|
|
if textbox.title then prnt(textbox.title,30,55) end
|
|
rect(40,70, 120, 80,8)
|
|
if textbox.value then
|
|
prnt(textbox.value,43,73)
|
|
if (math.floor(time()*4)%2)==0 then
|
|
prnt("_",43+#textbox.value*4,73)
|
|
end
|
|
end
|
|
|
|
local tecla=btnp()
|
|
if tecla>=4 and tecla<=39 then
|
|
textbox.value=textbox.value..string.sub(keyvalues,tecla,tecla)
|
|
elseif tecla==KEY_PERIOD then
|
|
textbox.value=textbox.value.."."
|
|
elseif tecla==KEY_BACKSPACE then
|
|
textbox.value=string.sub(textbox.value,1,-2)
|
|
elseif tecla==KEY_RETURN then
|
|
update=textbox.old_update
|
|
textbox.return_function(textbox.value)
|
|
end
|
|
end
|
|
} |