It looks like you're new here. If you want to get involved, click one of these buttons!
This is my code:
CreateTopicPage = class()
function CreateTopicPage:init()
self.text = {title = "Title here", message = "Message is here and\nnew line testnction"}
self.buttons = {"q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","m",",",".","?", "1", "2","3","4","5","6","7", "8", "9", "0"}
self.xy = 64
end
function CreateTopicPage:draw()
fill(textcolor)
font("Arial-BoldMT")
text(self.text.title, 500, 625)
for x = 1, 14 do
self.buttons[x] = {}
for y = 1, 3 do
self.buttons[x][y] = {}
strokeWidth(0)
fill(255, 255, 255, 255)
rect(x * self.xy, y * self.xy, self.xy, self.xy)
fill(textcolor)
text(#self.buttons, x * self.xy + self.xy/2, y * self.xy + self.xy/2)
end
end
end
function CreateTopicPage:touched(t)
end
function CreateTopicPage:keyboard(key)
end
I want to know how to place instead text(#self.buttons, x * self.xy + self.xy/2, y * self.xy + self.xy/2)
the letters that are called in the table self.buttons = {"q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","m",",",".","?", "1", "2","3","4","5","6","7", "8", "9", "0"}
Comments
try this
@Ignatz it is returning now this error:
@TokOut - you have to learn to debug code, yourself. Try to work out what is going wrong,
What I understand: You gave me an example where self.buttons[n] is a table but a string is expected
The reason is that you have TWO (2) tables with the name self.buttons. One has keyboard characters, the other is a table of x,y positions.
It works now, how to make now the touch? @Ignatz, Thx for help!
What don't you understand about touch?
I mean how to specify the buttons action I know that you can make them with for x = the same as in draw, but how to make the action of them?
I've explained this in blog posts and my ebooks, and there are lots of posts about touch.
Please do some reading before asking someone to write the code for you. We don't have time to explain everything to every new person. We expect you to learn what you can, then try to write the code.
Ok, where is it located?
I've told you more than once where my blog posts and my ebooks are
You can also search the forum
@Ignatz, this error appears by using your ebook:
https://coolcodea.wordpress.com/2013/06/19/index-of-posts/#more-8884
So I made a the touch function, but how to make instead
if a==7 and b==2 then
Plz help, Thx!
Help plz!
It's time you start helping yourself. There's tutorials on buttons, tutorials on touch, plus plenty of examples of both of them on the forum. You've been on the forum for 2 months, and everything you're asking about is just basic programming. You didn't make a touch function, you just put a bunch of code in a function called touched(). How does the code in the question you asked relate to anything in the code you posted for touch. You want help, READ THE TUTORIALS, and practice with small programs. Once you understand the basics, you can write the programs you want without asking for help.
I am pretty sure this could be make shorter. I made it myself ;-(
The nice part is :
end end end end end end
(6x)Why do you keep posting chunks of code that doesn't mean anything to anyone except you. If the code can be made shorter than make it shorter. I don't think anyone is going to waste their time trying to do it for you.
@TokOut, it looks like you answered your own question about a=7,b=2 - which is good.
Now, making things shorter and better is a skill that can only be acquired with practice. Try it, and then when you fail, try again. At some point, if you are serious about learning to program, you will succeed.
Maybe something like
self.letter[n]
@mentioned {Will mention everyone}
How to create objects? I already have the class and all the data, but how to create new objects?
Once more: the ebook 'Lua for beginners' by Ignatz, chapter 11, tells you all the basic stuff about classes you need to know. It can be found in the wiki or here:
https://www.dropbox.com/sh/mr2yzp07vffskxt/AABlplSGGFBTu8FzQy94lteua/Lua for beginners.pdf
I haven't dropbox
you don't need dropbox.
you can ignore the login message
Though Dropbox is by far the easiest way of managing your Codea assets IMO, so should be something every Codea user has.
@yojimbo2000, @Ignatz, markdown and GitHub - better then drop
@TokOut - of course, you would know, being such a Codea expert
Keyboard class: < Codea Ralk is better! >
Shouldn't the BCK key delete the previous letter?
And shouldn't the class return the whole string?
That's just an example! How to use it will be from you. This could be also used as calculator buttons. But that's just an example, which means only the start code