Skip to content

Commit 7128ee6

Browse files
GunkiratGunkirat
authored andcommitted
Added open and close functionality of Soft keyboard
1 parent daf0c61 commit 7128ee6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

core/src/processing/core/PApplet.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.regex.*;
3434
import java.util.zip.*;
3535

36+
import android.view.inputmethod.InputMethodManager;
3637
import android.app.Activity;
3738
import android.content.*;
3839
import android.content.pm.PackageManager;
@@ -766,6 +767,18 @@ public boolean checkPermission(String permission) {
766767
return false;
767768
}
768769
}
770+
771+
public void openKeyboard() {
772+
Context context = surface.getContext();
773+
InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
774+
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
775+
}
776+
777+
public void closeKeyboard() {
778+
Context context = surface.getContext();
779+
InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
780+
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
781+
}
769782

770783

771784
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

0 commit comments

Comments
 (0)