native.newTextField problem

I am attempting to write an example BMI calculator program using two text fields. One to enter the height and the other for the weight - so it should fairly simple and obvious to complete!

I am using the Windows based simulator (build 2100-free public download) and so these fields do not function as I would expect - on the actual Android device the first text box works fine (cursor inside box, keyboard shows, type number value) but the second does not. You cannot even click into the box. I have attached the screen shot and code  have used. I’m sure that it is a simple problem to rectify and the code may not be the best.

Can anyone help me solve the problem and even tidy up the code?

Thanks! … :slight_smile: Robert

Hi,

try changing these:

field1.font = native.newFont( native.systemFontBold, 18 )

and

field2.font = native.newFont( native.systemFontBold, 18 )

I looked in ADB and got this error message:

I/Corona (19646): C:\Users\Jefecito\Downloads\BMI\main.lua:103: bad argument #3 to '?' (native.Font expected, got userdata) I/Corona (19646): stack traceback: I/Corona (19646): [C]: ? I/Corona (19646): [C]: ? I/Corona (19646): C:\Users\Jefecito\Downloads\BMI\main.lua:103: in function 'setUpTextInputFields' I/Corona (19646): C:\Users\Jefecito\Downloads\BMI\main.lua:121: in main chunk I/Corona (19646): Runtime error 

I changed those value and now it works for me.

Best regards,

TOmas

Thanks Tomas,

That’s just brilliant - what you suggested works. I need to change the font size from 18 as it is too small for this particular exercise.

Thanks,

Robert

Hi,

try changing these:

field1.font = native.newFont( native.systemFontBold, 18 )

and

field2.font = native.newFont( native.systemFontBold, 18 )

I looked in ADB and got this error message:

I/Corona (19646): C:\Users\Jefecito\Downloads\BMI\main.lua:103: bad argument #3 to '?' (native.Font expected, got userdata) I/Corona (19646): stack traceback: I/Corona (19646): [C]: ? I/Corona (19646): [C]: ? I/Corona (19646): C:\Users\Jefecito\Downloads\BMI\main.lua:103: in function 'setUpTextInputFields' I/Corona (19646): C:\Users\Jefecito\Downloads\BMI\main.lua:121: in main chunk I/Corona (19646): Runtime error 

I changed those value and now it works for me.

Best regards,

TOmas

Thanks Tomas,

That’s just brilliant - what you suggested works. I need to change the font size from 18 as it is too small for this particular exercise.

Thanks,

Robert