I am seeking some expert advice, in regards to how to display the resident popup keyboard in my monogame app.
I have a game/app which I have been working on full time for over a year now. It started out as an XNA C# game and I migrated it to Monogame over a year ago. It is primarily a mobile game, and once published I think that it will bring more positive awareness to the Monongame community, and to the power of C#.
Anyway, I need to know how to display the resident popup keyboard which comes with Android. I would also like to have this work on IOS as well.
The problem is that I don’t see any current documentation on how to get the Android popup keyboard to display. Can anyone provide some tested C# code which will bring up the Android resident popup keyboard?
Or could you point me to a valid article on the web which would show me how do use the resident phone keyboard?
I actually struggled with this a lot in the relatively recent past. The good news is if you can get away with only needing a single line of text from the user at a time, the easiest and most reliable way to handle this is using a neat little hidden gem in MG: Class KeyboardInput | MonoGame Documentation
string simpleString = KeyboardInput.Show("Need some text:", null);
This works in both Android and iOS. It can be seen in the “Join Game” functionality of our game, Party Words.
If your use-case isn’t as simple as “give me a single line of text and press submit”, life is going to get tough but not impossible. Before I discovered that nice gem of MG, I was attempting to do this myself listening to keystrokes and what not. At least for Android, you can pretty easily setup event listeners in your main Activity for keyboard show/hide/keypress and fire off a function to toggle the keyboard open/close. However, doing so conflicts a lot with MG stuff and you’ll run into a lot of issues where your keystroke events are repeated and maybe other similar issues. I believe setting up custom keystroke handling would require you to dive into the MG source and maybe piggyback off its event listeners, override them entirely, or something else like that.
MessageBox appear to be missing from the new “Reference” API docs for
I’m away from my work while visiting family for the holiday weekend. I’ll try this out when I get back in my office. Thanks so much.