mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-01-06 13:27:48 +00:00
Added SDL_StartTextInputWithProperties()
This allows you to customize the text input so you can have numeric text entry, hidden passwords, etc. Fixes https://github.com/libsdl-org/SDL/issues/7101 Fixes https://github.com/libsdl-org/SDL/issues/7965 Fixes https://github.com/libsdl-org/SDL/issues/9439
This commit is contained in:
@@ -1375,9 +1375,11 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
*/
|
||||
static final int HEIGHT_PADDING = 15;
|
||||
|
||||
public int input_type;
|
||||
public int x, y, w, h;
|
||||
|
||||
public ShowTextInputTask(int x, int y, int w, int h) {
|
||||
public ShowTextInputTask(int input_type, int x, int y, int w, int h) {
|
||||
this.input_type = input_type;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.w = w;
|
||||
@@ -1405,6 +1407,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
} else {
|
||||
mTextEdit.setLayoutParams(params);
|
||||
}
|
||||
mTextEdit.setInputType(input_type);
|
||||
|
||||
mTextEdit.setVisibility(View.VISIBLE);
|
||||
mTextEdit.requestFocus();
|
||||
@@ -1419,9 +1422,9 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static boolean showTextInput(int x, int y, int w, int h) {
|
||||
public static boolean showTextInput(int input_type, int x, int y, int w, int h) {
|
||||
// Transfer the task to the main thread as a Runnable
|
||||
return mSingleton.commandHandler.post(new ShowTextInputTask(x, y, w, h));
|
||||
return mSingleton.commandHandler.post(new ShowTextInputTask(input_type, x, y, w, h));
|
||||
}
|
||||
|
||||
public static boolean isTextInputEvent(KeyEvent event) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.view.inputmethod.InputConnection;
|
||||
public class SDLDummyEdit extends View implements View.OnKeyListener
|
||||
{
|
||||
InputConnection ic;
|
||||
int input_type;
|
||||
|
||||
public SDLDummyEdit(Context context) {
|
||||
super(context);
|
||||
@@ -20,6 +21,10 @@ public class SDLDummyEdit extends View implements View.OnKeyListener
|
||||
setOnKeyListener(this);
|
||||
}
|
||||
|
||||
public void setInputType(int input_type) {
|
||||
this.input_type = input_type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCheckIsTextEditor() {
|
||||
return true;
|
||||
@@ -51,8 +56,7 @@ public class SDLDummyEdit extends View implements View.OnKeyListener
|
||||
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
|
||||
ic = new SDLInputConnection(this, true);
|
||||
|
||||
outAttrs.inputType = InputType.TYPE_CLASS_TEXT |
|
||||
InputType.TYPE_TEXT_FLAG_MULTI_LINE;
|
||||
outAttrs.inputType = input_type;
|
||||
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI |
|
||||
EditorInfo.IME_FLAG_NO_FULLSCREEN /* API 11 */;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user