Keyboard

http://ruilov.posterous.com/keyboard-v1

Edit: v3 here http://ruilov.posterous.com/keyboard-v3

I took snapshots of the keyboard on the IPad, converted to grayscale and did some encoding to reduce the file sizes, and saved as project data.

Will add more textbox functionality next, like resetting the text and being able to place the cursor in the middle of the text.

Cool. I’ll try to try it when I get to my iPad.

Could u plz use pastebin.com for sharing codes?:D-i have problems with this website

@Sajjad. Try going to posterous.com using mobile Safari on your iPad instead of Codea’s own built-in browser. If you then click and hold on the file you should be able to open it in Codea…

@Sajjad, what’s the problem with it? Works well for me

@ruilov - you’re a genius! It never occurred to me to take a shot of the regular keyboard - this looks awesome, and works very well. You even have keyclick! A+, 10 poins to @ruilov!

The only caveat is its really big - but until we get jpg/png/gif/spritepack-upload, you can’t avoid that…

@Bortels, I pushed myself to make the file smaller because I knew you’d say that :slight_smile:

I have no issue with being big, it’s 1.2 megs, the storage of old floppys. The issue I have is with it being slow. Can’t think of how to avoid slowness in the current release though.

heh, yeah, I almost didn’t comment on the size because I saw you worked on encoding it to make it smaller. I’m old - the part of my brain that looks at data when I’m coding still lives in an 8-bit 90k floppy disk 300 baud modem world…

That’s terrific, just very impressive on every point.

Hmmm. The keyboard normally displayed on a portrait screen would be darn near perfect fora standard displaymode setup.

Ah good idea. I should be able to get that added too, but first maybe I’ll just see what happens if I display the sprite with smaller width,height

Here’s v2: http://ruilov.posterous.com/keyboard-v2

More textbox functionality. Crop text to fit in the box. Allow placing the cursor in the middle of the text. Reset button.

@Mark, added a standard mode. The scaled down sprites don’t look that great but I think will do. Keyboard.setDisplayMode(STANDARD) to turn it on.

http://ruilov.posterous.com/keyboard-v3

Genius! Wow! Amazing!

Nice work.

Does anyone else get a crash when opening up the function list in the Codea editor and scrolling down a bit in the list of functions? This is with the v2 code.

I had it do that once! Re-ran codea and it was fine. Maybe some really-big-project bug? (Yes, 1.3 megs isn’t “big” - but for a Codea project, it’s huge… I doubt they tested too much with giant blobs of image data…)

@Eric I get a crash too. @Twolivesleft, is there somewhere where you’d like us to post bug reports?

This is with ipad2 on the latest os (5.1 or something like that) on either v2 or v3 of the keyboard code

This is so cool. I can’t wait to see where it leads us.

@ruilov your keyboard is absolutely amazing! The function browser crash is actually fixed in Codea 1.2.6, which is still waiting for approval (also has reorderable tabs so you don’t have to use alphabetical class names).

Also, just note you can read the current displayMode by calling displayMode() without any arguments. So you can set your keyboard’s display mode automatically if you like. That is:

if displayMode() == STANDARD then
    -- show keyboard in standard mode
else
    -- show keyboard in fullscreen
end

You can report issues here in the future though: https://bitbucket.org/TwoLivesLeft/codea/issues

@Simon, I didn’t know you could read the displayMode, thanks!

speaking of cursor control, here’s a new version of the keyboard code. Now that we have native support for keyboard and text (remember when we didn’t?) all that this code needs to do is handle the cursor and display of text.

http://www.youtube.com/watch?v=D9UhzZz6pyY

Unfortunately it doesn’t handle left/right keys (from a bluetooth keyboard) as those keys don’t trigger a keyboard(key) call

function setup()
    textboxes = {Textbox(10,HEIGHT - 100,250),Textbox(10,HEIGHT - 200,WIDTH - 100)}
    textboxes[2]:setFontSize(50)
    textboxes[2].fontProperties.fill = color(255, 0, 0, 255)
    textboxes[2].borderColor = color(14, 255, 0, 255)
end

function draw()
    background(0, 0, 0)
    for _,textbox in ipairs(textboxes) do textbox:draw() end
end

function touched(touch)
    for _,textbox in ipairs(textboxes) do textbox:touched(touch) end
end

function keyboard(key)
    for _,textbox in ipairs(textboxes) do textbox:keyboard(key) end
end