Best way to implement a "soft" keyboard


I am building a user interface on an RPI, and I have

many text-fields that the user may need to enter data into.
There is a touch-screen, but no “real” keyboard on this unit.
The “matchbox” keyboard for RPI is far from ideal, as
I want a keyboard that I can pop-up and hide all from Xojo,
not the O/S layer.

I was going to just make another window that had buttons
that would add the “pressed” buttons to a string, but this
got hard fast. For example, if a user clicked on textfield1,
it would be “easy” to put in the
event handler, but how would I get the data back into
this text box when the user hit the soft “enter” key?

I can kluge my way into something that works, no doubt,
but I wanted to ask the “experts” how to best handle this.

(no, I cannot attach a “real” keyboard and just be done,
boss’s orders!)



just an off the top of the head…

  • when you click on a textfield, store a reference that can be used by the “soft keyboard”
  • might have to create a special subclass of TextField/area but that shouldn’t be a big deal
  • create the “soft keyboard” as a container control. and all it needs to do it manipulate the passed reference (this way it isn’t tied to any specific textfield/area)

(assumes that RPI has container controls etc… I don’t do RPI, just desktop :slight_smile: )

I suppose you are talking about a Windows tablet ?

isn’t RPI a Raspberry PI?

Acronyms, acronyms… :smiley:

Never mind.

store a reference that can be used by the “soft keyboard” ? can you show me how to do this?

If you don’t want to construct your own keyboard in Xojo…
I’ve not tried this, but you can install a screen keyboard like this:-

Then, I guess, you need to find the its path/taskname and run that task from Xojo whenever you want to pop it up if it is not already running.

He actually said “I want a keyboard that I can pop-up and hide all from Xojo, not the O/S layer.”

[quote=452928:@Luigi Faustini] but how would I get the data back into
this text box when the user hit the soft “enter” key?[/quote]

Examples > Desktop > Windows > InputWindow

I implemented a software keyboard for my Raspberry Pi: The Comvette Project

Download the Comvette source code and you should be able to grab the keyboard from my project and drop it into your project.


One of the UI techniques I’ve seen in some applications is to actually have each field trigger a window with it’s own input field – combined with a keyboard, this is the “input device”. This is common in video game consoles, for instance, where text input is done with a game controller. Once the input is complete, the user commits the edit, and the text is then copied into the “field” (which may as well be a button to be honest).

Example for inspiration:

(In this case the red box shows the menu item clicked, which prompts for input in a completely separate window.)

The click event of the text field would be something like this:

wInputBox.EditField = me ' Store a reference to the field we're editing
wInputBox.txtInput.Text = me.Text ' Store the current value

wInputBox is just a Window object with a text field, a EditField property (of type TextField, to store a reference to the field actually being edited) and your keyboarded interface. The keyboard interface should include a “Done” button, which when clicked has this code:

self.EditField.Text = txtInput.Text

The character buttons you can probably figure out but something as simple as a control array which contains all characters that can be entered as separate buttons. The Caption of each button then can be used in a single one click event for all the characters + Backspace button:

if me.Caption = "Backspace" then
    if Len(self.txtInput.Text) > 0 then self.txtInput.Text = self.txtInput.Text.Left(Len(self.txtInput.Text)-1) ' Remove the last character
    self.txtInput.Text = self.txtInput.Text + me.Caption ' Add the character
end if

This could of course be made more complete with a “cursor”, arrow keys, delete button, shift button, etc.

I just threw together a quick example:

Doesn’t support non-ASCII characters (yet?) and doesn’t have cursor support but it’s the general idea and it works pretty well.

All of you guys are Frek’n AWESOME !!!
Thank you so much for the help!!! I am
looking at all options now. THANK YOU!!!


Looking at your code now… and trying to understand / learn. (Thanks again!)
How did you make the wInputBox? Did you drag and drop the (roughly) 64
buttons on to the screen? Is there an “easy” way to do that or did you manually
place them?? (and more questions to follow – sorry!!)

I manually dropped one button, sized it, then copied it to make a row, then copied the row 5 more times. It took about 5 minutes to do this way. There are ways to do this in code but this is a lot easier for something like this.

I just figured that out too… Group Copy paste is a wonderful thing!
Thanks again!