Skip to content

Commit 4979e26

Browse files
committed
fix focus
1 parent 698b6c2 commit 4979e26

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonActivity.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,16 @@ public void run() {
404404
}
405405
});
406406
}
407+
408+
409+
public void requestFocusForMainView() {
410+
runOnUiThread(new Runnable() {
411+
public void run() {
412+
Log.v(TAG, "requestFocusForMainView is getting focus now.");
413+
getSurface().requestFocus();
414+
}
415+
});
416+
}
407417

408418
public void removeLoadingScreen() {
409419
runOnUiThread(new Runnable() {

pythonforandroid/bootstraps/sdl2/build/src/patches/SDLActivity.java.patch

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@
8181
SDLActivity.nativeRunMain(library, function, arguments);
8282

8383
Log.v("SDL", "Finished main function");
84+
@@ -1993,6 +2018,9 @@ class DummyEdit extends View implements View.OnKeyListener {
85+
if (event.getAction()==KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
86+
if (SDLActivity.mTextEdit != null && SDLActivity.mTextEdit.getVisibility() == View.VISIBLE) {
87+
SDLActivity.onNativeKeyboardFocusLost();
88+
+ // if targetSdkVersion >= 28, we explicitly need to give back focus
89+
+ // see https://github.com/spesmilo/electrum/issues/6276
90+
+ SDLActivity.mSurface.requestFocus();
91+
}
92+
}
93+
return super.onKeyPreIme(keyCode, event);
8494
@@ -2002,7 +2028,7 @@
8595
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
8696
ic = new SDLInputConnection(this, true);

0 commit comments

Comments
 (0)