openfl / lime

A foundational Haxe framework for cross-platform development
https://lime.openfl.org/
MIT License
761 stars 375 forks source link

Emoji text input no longer works in Windows (html5 target) #1655

Closed johnridges closed 1 year ago

johnridges commented 1 year ago

The change in HTML5Window.hx of the Input Element type from 'text' to 'password' (commit e03cc18) has disabled emoji input in Windows (using window-period). This change should only be made for the Android platform.

joshtynjala commented 1 year ago

Unfortunately, there's no way to make the change only for the Android platform, since it's the same compiled output for all platforms.

You can add the lime_enable_html5_ime define to restore the old behavior, if it helps.

player-03 commented 1 year ago

Ignore my earlier comment. I forgot that this was HTML5 target vs. HTML5 target, not HTML5 target vs. Android target.

That said, there should still be a way to detect platform at runtime...

Edit: based on a quick search, how about this?

#if lime_enable_html5_ime
textInput.type = 'text';
#else
if(js.Browser.navigator.userAgent.indexOf("Android") >= 0) {
    // use password instead of text to avoid IME issues
    textInput.type = 'password';
} else {
    textInput.type = 'text';
}
#end
joshtynjala commented 1 year ago

Other than checking user agent, which isn't reliable since it can be changed, I'm not sure that there's a good way to detect Android.

Ideally, we'd figure out how to make IME input work in html5. It's a pretty quirky situation, though, with our hidden HTMLInputElement.

player-03 commented 1 year ago

which isn't reliable since it can be changed

So a user can spoof what system they're on to force the app's keyboard behavior to be slightly worse? It should still work for the majority.

joshtynjala commented 1 year ago

Yeah, I guess it's not terrible. I won't argue if you want to implement that.

player-03 commented 1 year ago

At least for now, I'd say.

Edit: also, HTML5Window already uses userAgent in one other place.