Native keyboard sample code?

2 replies [Last post]
meadmesiter
User offline. Last seen 1 year 51 weeks ago. Offline
Joined: 11 Feb 2010

The example in the documentation doesn't really demonstrate the usage very well. There's no sample code for the native text field/keyboard etc. Some clear examples would be nice.

Also, why is there no "done" button when the keyboard pops up?

Replies

evank
User offline. Last seen 1 year 4 weeks ago. Offline
Joined: 16 Sep 2009

Hi, meadmesiter. The "Social/Twitter" sample code shows how to implement the keyboard in a real-world situation, including event responses. But let us know if you have any further questions beyond that example.

Whether a "Done" button is appropriate depends on context and interface design. You can implement it by creating a button in Corona and calling a function that sets the keyboard focus to "nil":

native.setKeyboardFocus( nil )

...which will make the keyboard go away. Alternatively, you could detect touches from the screen not covered by the keyboard, and then dismiss it based on that event; this is also a widespread design practice in iPhone apps. It comes down to what you think is the right interface for your specific app.

gervaziointellix
User offline. Last seen 39 weeks 6 days ago. Offline
Joined: 1 May 2011

I am also having trouble to find docs/samples on keyboard use.
I writing a game for "racing a car". The user will user the keyboard to move the car, left, right,up, down. How to handle and capture those events?. Will it work on the simulator?

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.