Closed makrohn closed 7 years ago
Mouseless devices don't have character keys, so it's useless to set focus to inputbox because we can't type text. We only can use default names instead.
I didn't know if my mouseless devices we meant, for instance, a Wii which might have a Wiimote and a USB keyboard, or just game controllers.
I think hitting enter to activate/deactivate focus on the input widget is a good idea. We'll reclassify this as a feature instead of a bug because the use case is pretty obscure. We provided default names for hero portraits so that typing a name isn't required.
SDL 2 has SDL_StartTextInput, SDL_HasScreenKeyboardSupport, and SDL_IsScreenKeyboardShown, which could help us handle this on devices without physical keyboards
I've implemented Clint's idea of having Enter toggle WidgetInput's edit state. I also made a few improvements to WidgetInput in general. It's now possible to control the cursor position with the arrow keys as one would expect from a text entry field.
I know I mentioned getting the on-screen keyboard working for touch devices, but I'll consider that a separate issue and mark this one as finished.
On-screen keyboard support has been added, so text input is possible on phones/tablets now. Since the keyboard usually covers up the area you're typing in, I've opted to display the WidgetInput text in a tooltip at the top of the screen (see image).
As I mentioned in #722, it is currently impossible to get to the text input field in GameStateNew if you're using mouseless controls.
Dorkster commented there:
"So far, we've mostly thought of mouse-less systems as systems that don't have a proper keyboard either, like the GCW-Zero. I think we could solve this by adding a way to toggle a WidgetInput's active state. In other words, press Enter to start typing, press Enter again to finish."