We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1614 - SDL for Android does not implement TextInput API
Summary: SDL for Android does not implement TextInput API
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: ARM Android (All)
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-03 08:30 UTC by Andrey Isakov
Modified: 2012-10-03 20:49 UTC (History)
0 users

See Also:


Attachments
TextInput implementation patch for Android against b85e863a507e (13.42 KB, patch)
2012-10-03 08:30 UTC, Andrey Isakov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Isakov 2012-10-03 08:30:25 UTC
Created attachment 965 [details]
TextInput implementation patch for Android against b85e863a507e

Hi!

I've found out in the process of porting one OS project to Android/SDL2 that there is no support for TextInput events/APIs on Android.
So I implemented some kind of initial support of that feature, and at the very least it seems to work fine with latin chars input with soft and hardware keyboards on my Moto Milestone2. I've also tried playing around with more complex IMEs, like japanese, logging the process and it seemed to work too. I'm not sure since the app itself I am working on does not have support for non-latin input.

The main point of the patch is to place a fake input view in the region specified by SDL_SetTextInputRect and create a custom InputConnection for it.
The reason to make it a separate view is to support Android's pan&scan on input feature properly. For details please refer to
http://android-developers.blogspot.com/2009/04/updating-applications-for-on-screen.html
Even though the manual states that SetTextInputRect is used to determine the IME variants position, I thought this would be a proper use for this too.

Anyway, please see the patch attached (against the rev b85e863a507e, sorry for the outdating). And I had to fix the paths by hand since I have included SDL snapshot in a git repo. I hope I did not mess the code too much, but this is still better than nothing, right?
Comment 1 Sam Lantinga 2012-10-03 20:49:57 UTC
The patch looks good, thanks!
http://hg.libsdl.org/SDL/rev/f2c03c06d987