Skip to content

Commit 2c705e8

Browse files
committed
open/close keyboard
1 parent d51849d commit 2c705e8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

core/src/processing/core/PApplet.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import android.view.SurfaceView;
4747
import android.view.View;
4848
import android.view.ViewGroup;
49+
import android.view.inputmethod.InputMethodManager;
4950
import processing.a2d.PGraphicsAndroid2D;
5051
import processing.android.AppComponent;
5152
import processing.data.*;
@@ -2391,6 +2392,22 @@ protected void nativeKeyEvent(android.view.KeyEvent event) {
23912392
}
23922393

23932394

2395+
public void openKeyboard() {
2396+
View view = surface.getRootView();
2397+
Context context = surface.getContext();
2398+
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
2399+
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
2400+
}
2401+
2402+
2403+
public void closeKeyboard() {
2404+
View view = surface.getRootView();
2405+
Context context = surface.getContext();
2406+
InputMethodManager imm =(InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
2407+
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
2408+
}
2409+
2410+
23942411
public void keyPressed() { }
23952412

23962413

0 commit comments

Comments
 (0)