This is what I am doing with my TextBoxes…
It is modified from the sample on Corona. Which…sigh… looks out of date…
------------------------------------------
-- \*\*\* Create native input textfields \*\*\*
-------------------------------------------
-- Note: currently this feature works in device builds or Xcode simulator builds only
-- Note: currently this feature works in device builds only
local isAndroid = "Android" == system.getInfo("platformName")
local inputFontSize = 18
local inputFontHeight = 30
if isAndroid then
-- Android text fields have more chrome. It's either make them bigger, or make the font smaller.
-- We'll do both
inputFontSize = 14
inputFontHeight = 42
end
myText = display.newText( "GJYyp@^", 20, 40,0,0, "QuadratSerial", 36)
myText:setTextColor( 255,0,0 )
defaultField = native.newTextField( 10, 120, 300, 30, fieldHandler )
-- o:addEventListener( 'userInput', listener )
-- WARNING: The 'listener' argument to native.newTextField( left, top, width, height [, listener] ) is deprecated. Call the object method o:addEventListener( 'userInput', listener ) instead.
defaultField.font = native.newFont( "Quadrat Serial", myText.height / 1.8 )
defaultField.align = "center"
myText:removeSelf()
myText = nil
-- Add fields to our new group
fields:insert(defaultField)
native.setKeyboardFocus( defaultField )
local bkgd = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
bkgd:setFillColor( 0, 0, 0, 0 ) -- set Alpha = 0 so it doesn't cover up our buttons/fields
What I did with my buddy in Corona irc to modify the IOS text is to get the height of the text printed to the device and scale based on that. I don’t really understand it, we got it working on iOS so that if it is on an iPAD the text in the textInput area is really small. But really small is better than cut off, so I shipped with it.
Now I really want to get this working for Android users. The fact that this is not automatic is maddening. I think it should default to always be the height of 1 line of textbox, unless you specify for some reason you want gynormous text in your textField.
I guess a lot of Corona Apps do not have an ‘Enter Text’ feature and there isnt a common FIT ALL solution to this.
[import]uid: 100299 topic_id: 35589 reply_id: 141459[/import]