author Sam Lantinga
Wed, 03 Oct 2012 20:49:16 -0700
changeset 6555 f2c03c06d987
parent 6392 fa7eb111f994
child 6631 47ab7ba21530
permissions -rw-r--r--
Fixed bug 1614 - SDL for Android does not implement TextInput API

Andrey Isakov 2012-10-03 08:30:25 PDT

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
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.
     1 <?xml version="1.0" encoding="utf-8"?>
     2 <manifest xmlns:android=""
     3       package=""
     4       android:versionCode="1"
     5       android:versionName="1.0">
     7     <uses-sdk android:minSdkVersion="5" />
     9     <application android:label="@string/app_name" android:icon="@drawable/icon">
    10         <activity android:name="SDLActivity"
    11                   android:label="@string/app_name">
    12             <intent-filter>
    13                 <action android:name="android.intent.action.MAIN" />
    14                 <category android:name="android.intent.category.LAUNCHER" />
    15             </intent-filter>
    16         </activity>
    17     </application>
    18 </manifest>