okay, so I’m trying to make a program that lets you type stuff on screen while the code is running(like when you press play not when you’re in the editor) the problem is to do this I made a table with all the letters of the alphabet and x and y positions. Then I made a function to test if I tapped any area where a letter was. Then I told lua to loop through the table and cocantinate it to a empty string
function check(x,y,x2,y2)
if x2 >= x and x2 < x and y2 >= y and y2 < y then
for I =1,#tbl do
b=b..tbl[I].a
break
end
end
end
However it will only return the letter “a” and I can’t figure out a way to check what letter I pressed so it will cocantinate the right letter each time. Any suggestions? Thanks
It would be awesome if you could make your own keyboard from scratch, but… it seems that the functions showKeyboard(), hideKeyboard(), keyboardBuffer(), and function keyboard(key) might be useful.
@ignatz, I know why it stops at “a”. The problem is it will print “a” no matter what letter I actually press. I can’t figure out a way to tell codea that if I press let’s say “w” that it will print “w” and stop. @SkyTheCoder, I’ll look into those functions thanks.
displayMode(FULLSCREEN)
supportedOrientations(LANDSCAPE_ANY)
function setup()
rectMode(CENTER)
showKeyboard()
tab={}
end
function draw()
background(40,40,50)
fill(255)
text("Type something then press return",WIDTH/2,400)
rect(WIDTH/2,450,200,50)
if rtn then
rtn=false
hideKeyboard()
showKeyboard()
end
fill(255,0,0)
text(keyboardBuffer(),WIDTH/2,450)
for a,b in pairs(tab) do
text(b,WIDTH/2,HEIGHT-a*30 )
end
end
function keyboard(k)
if k==RETURN then
table.insert(tab,keyboardBuffer())
rtn=true
end
end