Keyboard function

Hello, I’m implementing a local highscore system in my game, and I think(hmm, but what if the device owner let another person plays my game, what about saving the score and the name that the person will input.

Well, my question is:

Is there any way of calling the iPhone/Android touchkeyboard to get someone’s names, or I’ll have to do a whole keyboard hand-made(this one would be gross).
Thank you for the support! [import]uid: 69287 topic_id: 12959 reply_id: 312959[/import]

On my settings screen I added this block of code:

[lua] playerNameField = native.newTextField( 52, 170, 200, 28, playerNameCallback )
playerNameField.text = playerName
playerNameField.x = display.contentWidth / 2
settingsGroup:insert(playerNameField)[/lua]

The assumptions are here that I have a variable named playerName that has the current player’s name in it, or a default if it’s not set. That value is saved in my settings file so it persists from game to game and that I load it in with a new run of my app.

There is another bit that goes with it, the Call Back function for when the player taps the enter button:

[lua]local function playerNameCallback(event)
if ( “submitted” == event.phase ) or ( “ended” == event.phase) then
playerName = playerNameField.text
native.setKeyboardFocus( nil )
saveSettings()
end
end[/lua]

Now the assumption here is that this function will be defined before the first block of code since I didn’t do forward declarations.

Now here is the GOTCHA! This only works on the device (or in the case of iOS, the Xcode simulator too). It WILL NOT work on the Corona SDK simulator. So you will have to be able to build for device which means in the case of iOS, having your paid developer’s subscription, having setup your certificates and provisioning profiles, etc.

Rob
[import]uid: 19626 topic_id: 12959 reply_id: 47568[/import]

What a faster answer!

Thank you like… A LOT , I couldn’t find it anywhere. [import]uid: 69287 topic_id: 12959 reply_id: 47570[/import]