Fix character input in mobile web browsers.
The way sokol_app.h currently aquires character input (via keyboard events) doesn't work on all mobile browsers (most importantly: in Android Chrome).
Instead an input event handler needs to be attached to the helper text field, e.g. in sapp_js_create_textfield:
const _sapp_inp = document.createElement("input");
//...
_sapp_inp.addEventListener("input", function(_sapp_event) {
console.log(_sapp_event.target.value);
_sapp_event.target.value = '';
});
//...
...this grabs the last text input (which may be many characters in case of copy-paste? => need to investigate how this would interfere with the regular clipboard stuff) and then clears the text field in anticipation of the next call of the input handler.
The remaining 'challenge' is now to convert the UTF-8 string to UTF-32, and then send an SAPP_EVENTTYPE_CHAR event for each code point in the input string.
Additional notes:
- the textfield input method should probably be gated behind an
User Agent == Androidcheck, because on desktop platforms all that stuff isn't needed (unless it would help with IME input? => but currently textfield input doesn't appear to work on desktop browsers anyway) - on iOS, evented text input seems to work in iPad simulator, need to check on device (but can't check on an actual iPhone, only iPad)
Started implementing here, but stalled until I can test on Android:
https://github.com/floooh/sokol/tree/sokol-app-emsc-mobile-char-input
...alphanumeric input works in Android browsers (not yet tested tested on Safari).
Remaining problem: the backspace key behaves weird, required multiple presses before backspace are 'detected'?
Also, opening the keyword seems to require two taps into a Dear ImGui text field (at least on Android Chrome?)
...it's probably hopeless, see all the issues in https://github.com/floooh/sokol/pull/820
Won't fix.