Fixed bug 1564 - SDL has no function to open a screen keyboard on Android.

Philipp Wiesemann implemented a general on-screen keyboard API for SDL, and I switched iOS code over to use it.
This commit is contained in:
Sam Lantinga 2012-08-11 10:15:59 -07:00
parent 5570852b58
commit bf2304785f
19 changed files with 332 additions and 131 deletions

View file

@ -9,6 +9,7 @@ import javax.microedition.khronos.egl.*;
import android.app.*;
import android.content.*;
import android.view.*;
import android.view.inputmethod.InputMethodManager;
import android.os.*;
import android.util.Log;
import android.graphics.*;
@ -106,13 +107,33 @@ public class SDLActivity extends Activity {
}
// Messages from the SDLMain thread
static int COMMAND_CHANGE_TITLE = 1;
static final int COMMAND_CHANGE_TITLE = 1;
static final int COMMAND_KEYBOARD_SHOW = 2;
// Handler for the messages
Handler commandHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (msg.arg1 == COMMAND_CHANGE_TITLE) {
switch (msg.arg1) {
case COMMAND_CHANGE_TITLE:
setTitle((String)msg.obj);
break;
case COMMAND_KEYBOARD_SHOW:
InputMethodManager manager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
if (manager != null) {
switch (((Integer)msg.obj).intValue()) {
case 0:
manager.hideSoftInputFromWindow(mSurface.getWindowToken(), 0);
break;
case 1:
manager.showSoftInput(mSurface, 0);
break;
case 2:
manager.toggleSoftInputFromWindow(mSurface.getWindowToken(), 0, 0);
break;
}
}
break;
}
}
};
@ -155,6 +176,10 @@ public class SDLActivity extends Activity {
mSingleton.sendCommand(COMMAND_CHANGE_TITLE, title);
}
public static void sendMessage(int command, int param) {
mSingleton.sendCommand(command, Integer.valueOf(param));
}
public static Context getContext() {
return mSingleton;
}
@ -590,4 +615,3 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
}
}