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 kepayd_window.show 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!)
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 )
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.ShowModal
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
self.Close
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
else
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.
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.