Pop up keyboard when selecting text field

I am trying to get a keyboard to pop up in the simulator when I select a text field, and then disappear when the text is entered . When I click in the text field no keyboard shows up.

[lua]local datefield = native.newTextField((display.contentWidth*.05), (display.contentHeight*.2), (display.contentWidth*.3), 30, DateGetFocus)
datefield.isEditable=true

local function DateGetFocus( event )
local phase = event.phase

if “began” == phase then
datefield.inputType= “number”
end

if “selected” == phase then
datefield.inputType = “nil”
end
end[/lua]

Should I handle the keyboard selection in some other way? Or is it just an error with my implementation?

Using Corona Simulator version (2013.6.3) and Mac OSX 10.8.5

There will be no keyboard in simulator. You have one under your hands :slight_smile: On iphone keyboard appears because there is no physical one.

So there is no way to determine if the proper keyboard type (or any keyboard) will pop up when selecting the text field without compiling and loading onto a physical device?

Yes, keyboard is native part of os so it comes down to testing on device. You are luck to use xcode, windows do not even allow to type inside fields.

So, if I change the event handler to:

[lua]local function DateGetFocus( event )
local phase = event.phase

if “began” == phase then
testfield.text=“test”
end

end[/lua]

that should insert “test” into my sample text field when I click on the datefield?

I’m trying to see if the Date Get Focus function actually triggers when I select the datefield text box. Then I can be reasonably certain that it will cause the keyboard to pop up when I try and test on a device.

So far, that does not happen. Again, I am wondering if it’s a problem with how I have the event handler set up.

Hi @sdzafovic,

Did you follow the examples in the sample project located in your local Corona application folder?

CoronaSDK > SampleCode > Interface > NativeKeyboard

This should show you the basic functionality of this.

Best regards,

Brent Sorrentino

There will be no keyboard in simulator. You have one under your hands :slight_smile: On iphone keyboard appears because there is no physical one.

So there is no way to determine if the proper keyboard type (or any keyboard) will pop up when selecting the text field without compiling and loading onto a physical device?

Yes, keyboard is native part of os so it comes down to testing on device. You are luck to use xcode, windows do not even allow to type inside fields.

So, if I change the event handler to:

[lua]local function DateGetFocus( event )
local phase = event.phase

if “began” == phase then
testfield.text=“test”
end

end[/lua]

that should insert “test” into my sample text field when I click on the datefield?

I’m trying to see if the Date Get Focus function actually triggers when I select the datefield text box. Then I can be reasonably certain that it will cause the keyboard to pop up when I try and test on a device.

So far, that does not happen. Again, I am wondering if it’s a problem with how I have the event handler set up.

Hi @sdzafovic,

Did you follow the examples in the sample project located in your local Corona application folder?

CoronaSDK > SampleCode > Interface > NativeKeyboard

This should show you the basic functionality of this.

Best regards,

Brent Sorrentino