Posted: Thu Apr 18, 2013 3:40 pm Post subject: Editboxes
Well,
Is it possible to do this,
I have made an trainer for stats.
I want to allow in the editboxes to be written ONLY numbers
I tried the following,
Code:
function CEEdit1KeyDown(sender, key)
local text = control_getCaption(UDF1_CEEdit1)
print(text)
a = isKeyPressed(VK_0)
b = isKeyPressed(VK_1)
c = isKeyPressed(VK_2)
d = isKeyPressed(VK_3)
e = isKeyPressed(VK_4)
f = isKeyPressed(VK_5)
g = isKeyPressed(VK_6)
h = isKeyPressed(VK_7)
i = isKeyPressed(VK_8)
j = isKeyPressed(VK_9)
if a then print(0)
elseif b then print(1)
elseif c then print(2)
elseif d then print(3)
elseif e then print(4)
elseif f then print(5)
elseif g then print(6)
elseif h then print(7)
elseif i then print(8)
elseif j then print(9)
else
control_setCaption(UDF1_CEEdit1, text)
end
return key
end
Didn't prevent anything.
Don't see any option to set allowed characters _________________
I'm rusty and getting older, help me re-learn lua.
function CEEdit1KeyDown(sender, key)
if (string.byte(key)<string.byte('0')) or (string.byte(key)>string.byte('9')) then
key=nil
end
return key
end
Gonna test
Tested, backspace does not work nor the digit 6
Also found alternatives..
Code:
function CEEdit1KeyPress(sender, key)
if (tonumber(key))==0 then return key
elseif(tonumber(key))==1 then return key
elseif(tonumber(key))==2 then return key
elseif(tonumber(key))==3 then return key
elseif(tonumber(key))==4 then return key
elseif(tonumber(key))==5 then return key
elseif(tonumber(key))==6 then return key
elseif(tonumber(key))==7 then return key
elseif(tonumber(key))==8 then return key
elseif(tonumber(key))==9 then return key
else return end
end
which does not allows backspace.
but this does
Code:
function CEEdit1KeyPress(sender, key)
a = isKeyPressed(VK_0)
b = isKeyPressed(VK_1)
c = isKeyPressed(VK_2)
d = isKeyPressed(VK_3)
e = isKeyPressed(VK_4)
f = isKeyPressed(VK_5)
g = isKeyPressed(VK_6)
h = isKeyPressed(VK_7)
i = isKeyPressed(VK_8)
j = isKeyPressed(VK_9)
k = isKeyPressed(VK_BACK)
if a then return key
elseif b then return key
elseif c then return key
elseif d then return key
elseif e then return key
elseif f then return key
elseif g then return key
elseif h then return key
elseif i then return key
elseif j then return key
elseif k then return key
else return end
end
_________________
I'm rusty and getting older, help me re-learn lua.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum