TextBox Input!

+1
+1
+1
+1
…i need it sooooo much
i wanna establish a memo app… [import]uid: 25057 topic_id: 7076 reply_id: 41006[/import]

-10000 I win

:wink:

The new iOS 5 has a bunch of new text controls so we will implement those as soon as we can get the current build out the door and add a bunch of those new features.
c. [import]uid: 24 topic_id: 7076 reply_id: 41056[/import]

Hurray!! thank you Carlos…this is REALLY great to hear! What’s the ETA on the next release and any thoughts about providing an RTTI() in an upcoming release? We really need it for any meta-programming :wink:

The product gets better every week!!

[import]uid: 6175 topic_id: 7076 reply_id: 41058[/import]

Super excited to hear this finally has a timeline! :slight_smile:

Though also a little disappointed to hear it will be iOS5+ only and what that means for the timeline… and user exclusion, depending on when we’d decide to force our users to iOS5. In my mind, this puts practical use of it at least 7 to 9 months out from now.

Best wishes,
~~Kenn [import]uid: 13859 topic_id: 7076 reply_id: 41070[/import]

Great finally we have some infos about that…

And of course, I’m a little disappointed is going to be only iOS5+, so Kenn is right, probably 7 to 9 months out from now.

I guest the best thing to do, if you want to make a memo app, is probably use something like Titanium SDK…

[import]uid: 9158 topic_id: 7076 reply_id: 41094[/import]

actually - just wait and see what we got in store in a few days from today - but you will understand why one at a time please…

now serving #74 :wink:

c. [import]uid: 24 topic_id: 7076 reply_id: 41096[/import]

It’s been a few days, any news on better text input support. I’m holding off on coding a work around… but I’m not sure how much longer I can delay. [import]uid: 60707 topic_id: 7076 reply_id: 44354[/import]

+1 on this…

without the ability to control cursor position, we can’t simulate the in-field labels in a way that looks native… [import]uid: 6175 topic_id: 7076 reply_id: 44366[/import]

Any news? Been another month. I’m currently working on a work around, but it’s not pretty.

And will it work on Android? [import]uid: 11144 topic_id: 7076 reply_id: 46252[/import]

@gregh
Nope… I started this post something like 5 months ago, but still nothing.

There should be a major Corona update coming at the beginning of August… maybe with TextBox input support? I’m not holding my breath but who knows.

As for workarounds I tried to capture the text from a textfield with alpha 0 and update a textbox (there should be an example somewhere on the forum)… but honestly it worked pretty bad.

Probably the best option is to use a webview with a textbox form element and then send the text to corona (but I decided to don’t use it because the webview gray area while loading looks quite unprofessional).

What kind of workaround are you working on?
[import]uid: 9158 topic_id: 7076 reply_id: 46374[/import]

thanks @shedder. Yeah, there’s been mention of it maybe working with some help from iOS 5 coming out. But that leads me to believe that Android will be left in the dust. So, i’m going to keep working on a work around.

basic idea, and i’ll post it if it ever works out. Create a new invisible button over where I want the text to finally be placed. When the user clicks that, the keyboard pops up as well as a new textfield. Then the user types stuff in on the 1 lined textfield, presses return (or maybe a “submit” button). Then the textfield.text data gets sent to a “newParagraph” display text (See CrawlSpace Library for more info on creating Paragraphs. It’s awesome.). That newParagraph is placed over where that user clicked that original button. And using the newParagraphs, I can use whatever font I want. In this case, it’ll be a hand written font as i’m working on a workbook type app.

Then, i need to figure out a way to link the newParagraph text back to the popup textfield so if the user wants to edit the text, they can. Pretty sure it’s doable, i just need to work it out. I’m fairly new, so it takes me a bit longer on stuff like this.

Obviously not ideal, but i think it’ll work out ok for my situation.

remind me in a few weeks if i don’t post anything. i’m on like 5 different forums trying to figure this thing out. [import]uid: 11144 topic_id: 7076 reply_id: 46413[/import]

@gregh … Well that general concept won’t work because textfields are native … you can’t actually put anything on top of them. And you could only bring back multi-line text for edits via textfield one line at a time…

But in the spirit of tossing out brainstorming thoughts … :wink:

The idea I was playing with in my head, but haven’t gotten anywhere formulating – and hope I don’t have to and that Corona will deliver an easy solution in true corona form… involved using a textfield offscreen that the keyboard input would feed into …

… as each key is entered, the text is generated on screen using the newParagraph from crawlspace.

But that’s sorta the “easy” part. To make an “editable” textarea … where one could then “tap” and start typing in the middle… i think that becomes more complicated as to figuring out where one tapped within the text. You also can’t edit a newParagraph element (right?) you’d have to destroy and recreate as one typed initially or edited.

Perhaps for small functions it could be workable to actually create individual objects for each character typed and lined them up with a simple positioning loop that moves the Y " + yPlus" each time you have 20 or 30 or 40 characters on a line. Then you could “more easily” keep the objects for each character in an array and just change their x / y position to account for new characters being typed or inserted…

Given that each character would be it’s own object, I don’t know at what point Corona would poop out with too many objects. In a non-physics environment, it might be a whole lot? (I saw one youtube demo with 250 physics objects bouncing around causing some slowness – but we’re talking about small single character text objects, not bouncing.

Anyway…

~~Kenn [import]uid: 13859 topic_id: 7076 reply_id: 46564[/import]

What I really don’t understand is why the native TextBox element we can use in Corona is not editable.

I’m not 100% sure but I think that Corona TextBox element should be a UITextView (http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextView_Class/Reference/UITextView.html)… since the UITextView has a editable attribute, it shouldn’t be too hard to implement a multi-line editable textbox.
[import]uid: 9158 topic_id: 7076 reply_id: 46586[/import]

Still waiting on this as well.

@gregh - Let us know how your workaround goes. I’m going to try to hold out until after the new release to see if it fixes this issue. Also, I’ll check out the crawlspace games paragraph class. [import]uid: 60707 topic_id: 7076 reply_id: 46655[/import]

Hey guys. I got something working! It’s not fleshed out just yet, but i’ll work on it more on monday. Till then, check it out and see if you have any improvements or know how to make the “blank textfield” work.

You’ll need to build on your device to make it work. Formatted for iPhone. little odd on the iPad, but still works.

sorry for the mess of files. but i plan on fixing all that before putting this on the code exchange. This will be my first contribution to the friends of Corona.

copy/paste this into webbrowser.

send.awanadigitalstrategies.com/Corona/multilLine.zip
Special thanks to Adam from CrawlSpace. You rock! [import]uid: 11144 topic_id: 7076 reply_id: 46843[/import]

One way would be to serve a html page and form with textarea. Then you could grab the text from listener function. Not very elegant but I tried this and it actually worked.

Edit: Sorry, I just noticed that this was NOT an option. [import]uid: 49305 topic_id: 7076 reply_id: 49316[/import]

Yes jussi, that’s probably the best (only) option if you want a native textbox input (with auto-correction, magnifying glass and copy/paste).

And that solution would be pretty good if the webpopup didn’t show that ugly gray block when you open it (btw, that’s another thing that should be fixed).

@gregh I’ve tried running your example, but I can’t figure out how it works… I mean, I see a blue box, when I click on it a input textfield appears. I enter some text, and some of this text (not all) appear on the box. Could you check it?
[import]uid: 9158 topic_id: 7076 reply_id: 49403[/import]

This has been very frustrating. I wish Ansca would at least give us a notice on when we can expect this.

Any application that needs more than 40 characters of typing is a no go with Corona. That’s very big slice of business of the app store. I am actually starting to look into the XCODE sdk. Very sad! [import]uid: 8192 topic_id: 7076 reply_id: 49483[/import]

Here is a little trick I came up with. This uses the autoWrappedText function. Again, this is not ideal but tweakable for sure. Test in IOS simulator and tap the text.

main.lua:
[lua]function autoWrappedText(text, font, size, color, width)
if text == ‘’ then return false end

font = font or native.systemFont
size = tonumber(size) or 12
color = color or {255, 255, 255}
width = width or display.contentWidth

local result = display.newGroup()
local currentLine = ‘’
local currentLineLength = 0
local lineCount = 0
local left = 0
for line in string.gmatch(text, “[^\n]+”) do
for word, spacer in string.gmatch(line, “([^%s%-]+)([%s%-]*)”) do
local tempLine = currentLine…word…spacer
local tempDisplayLine = display.newText(tempLine, 0, 0, font, size)
if tempDisplayLine.width <= width then

currentLine = tempLine
currentLineLength = tempDisplayLine.width

else
local newDisplayLine = display.newText(currentLine, 0, (size * 1.3) * (lineCount - 1), font, size)
newDisplayLine:setTextColor(color[1], color[2], color[3])
result:insert(newDisplayLine)
lineCount = lineCount + 1
if string.len(word) <= width then

currentLine = word…spacer
currentLineLength = string.len(word)
else
local newDisplayLine = display.newText(word, 0, (size * 1.3) * (lineCount - 1), font, size)
newDisplayLine:setTextColor(color[1], color[2], color[3])
result:insert(newDisplayLine)
lineCount = lineCount + 1
currentLine = ‘’
currentLineLength = 0
end
end
tempDisplayLine:removeSelf();
tempDisplayLine=nil;
end
local newDisplayLine = display.newText(currentLine, 0, (size * 1.3) * (lineCount - 1), font, size)
newDisplayLine:setTextColor(color[1], color[2], color[3])
result:insert(newDisplayLine)
lineCount = lineCount + 1
currentLine = ‘’
currentLineLength = 0
end
result:setReferencePoint(display.CenterReferencePoint)
return result
end

local textarea
local kb
local textStorage = " "

local function updateText(txtstring, remove)
if remove then textarea:removeSelf( ) end
textarea = autoWrappedText( txtstring, native.systemFont, 24, {255,255,255}, nil );
textarea:setReferencePoint( display.TopLeftReferencePoint );
textarea.xScale = 1; textarea.yScale = 1;
textarea.x = 0; textarea.y = 20;
– this is a trick that ables us to delete chars and keyboard
– will not force us caps
kb.text = " x"
end

local checkText = function( event )
if string.len(kb.text) > 2 then
textStorage = textStorage…string.sub(kb.text, 3, -1)
updateText(textStorage, true)
elseif string.len(kb.text) == 1 then
if string.len(textStorage) > 1 then
textStorage = string.sub(textStorage, 1, -2)
end
updateText(textStorage, true)
end
end

local handlerFunction = function( event )
if ( “began” == event.phase ) then
– Note: this is the “keyboard appearing” event
Runtime:addEventListener( “enterFrame”, checkText )
elseif ( “submitted” == event.phase ) then
– user clicks “Return” on iPhone keyboard
textStorage = textStorage … “\n”
end
end
– put this somewhere out of sight
kb = native.newTextField( -500, 0, 500, 500, handlerFunction )

local process_txt = function()
native.setKeyboardFocus( kb )
end
updateText(“This is a test.”, false)
textarea:addEventListener( “tap”, process_txt )[/lua] [import]uid: 49305 topic_id: 7076 reply_id: 49762[/import]

Seems to work :slight_smile:

I am going to run some tests on it. But Great info. Thank you! [import]uid: 8192 topic_id: 7076 reply_id: 49763[/import]