Roku PhotoBridge Programming: Patterns and Pitfallsfrequal.com

Adding an On-Screen Keyboard

Summary

Sometimes you need the user to enter text into your application. Perhaps they need to enter a password or a name for a new file or folder. Whatever the reason, you'll need to provide a way for them to "type" in text using just the remote control.

Fortunately Roku has provided a keyboard window class sample code. This seciont shows how to integrate the keyboard window into your application, including showing it on-screen and handling entered text.

Showing the Keyboard

The keyboard is intended to be used as a child window of your application main window. You can construct it early in your application if you wish (during your main window is constructed, for example). When the time comes to show the keyboard, simply call Materialize on the keyboard to ause it to be shown on-screen.

[TBD -- sample code here]

The Key-Press Handler

The KeyboardWindow class provides keystrokes to a callback function. You must write the callback function to do something with received keypresses, and tell KeyboardWindow about your callback function so it knows where to send new keypresses.

You callback function should implement the OnEntryProc prototype, meaning that it should accept two parameters:

  • A CascadeString containing the entered text
  • A void pointer to data provided when the callback was registered
If you have just one keyboard and one receiver for the keyboard data, then you can ignore the second parameter. However, if you have multiple places where keybresses should go, but you want one handler function to dispatch them, then that data can hold a pointer to the object that should receive the keypresses and your dispatch can invoke a method on that object after casting the pointer.

In our example, we'll have the callback function pass the strings received back to the main window for rendering on the screen.

[TBD -- sample code here]


Last modified on 23 Nov 2006 by AO

Copyright © 2024 Andrew Oliver