mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-19 13:00:12 -07:00
Introduce toggling system for all keyboards
This commit is contained in:
parent
1f2d599ce5
commit
e74fb95f98
3 changed files with 52 additions and 32 deletions
|
|
@ -883,22 +883,23 @@ public class BaseMainActivity extends LoggableActivity {
|
|||
// Catch back as Esc keycode at another place
|
||||
sendKeyPress(LWJGLGLFWKeycode.GLFW_KEY_ESCAPE);
|
||||
}
|
||||
|
||||
public void hideKeyboard() {
|
||||
try {
|
||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
||||
if (getCurrentFocus() != null && getCurrentFocus().getWindowToken() != null) {
|
||||
((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).hideSoftInputFromWindow((this).getCurrentFocus().getWindowToken(), 0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void showKeyboard() {
|
||||
((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
|
||||
minecraftGLView.requestFocusFromTouch();
|
||||
minecraftGLView.requestFocus();
|
||||
|
||||
/**
|
||||
* Toggle on and off the soft keyboard, depending of the state
|
||||
* The condition is prone to errors if the keyboard is being hidden without the consent
|
||||
* of the current TouchCharInput
|
||||
*/
|
||||
public void switchKeyboardState(){
|
||||
if(touchCharInput.hasFocus()){
|
||||
touchCharInput.clear();
|
||||
touchCharInput.disable();
|
||||
|
||||
}else{
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
touchCharInput.enable();
|
||||
touchCharInput.postDelayed(() -> imm.showSoftInput(touchCharInput, InputMethodManager.SHOW_IMPLICIT), 200);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setRightOverride(boolean val) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue