mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-18 04:20:11 -07:00
Hide keyboard when out-of-focus
This commit is contained in:
parent
dfdf9e8670
commit
afed2315af
1 changed files with 19 additions and 8 deletions
|
|
@ -9,30 +9,41 @@ import android.view.*;
|
|||
import android.view.inputmethod.BaseInputConnection;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
public class MinecraftGLView extends TextureView
|
||||
{
|
||||
volatile BaseMainActivity ctx;
|
||||
// private View.OnTouchListener mTouchListener;
|
||||
public MinecraftGLView(Context context) {
|
||||
super(context);
|
||||
//setPreserveEGLContextOnPause(true);
|
||||
ctx = (BaseMainActivity) context;
|
||||
setOnFocusChangeListener(new OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean b) {
|
||||
if(!b) {
|
||||
((InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(view.getWindowToken(),0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public MinecraftGLView(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
//setPreserveEGLContextOnPause(true);
|
||||
setOnFocusChangeListener(new OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean b) {
|
||||
if(!b) {
|
||||
((InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(view.getWindowToken(),0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
|
||||
outAttrs.inputType = EditorInfo.TYPE_NULL;
|
||||
if(!isHardKB(this.getContext())) {
|
||||
Log.d("TypeableGLView","onCreateInputConnection");
|
||||
return new MinecraftInputConnection(this, false);
|
||||
}else{
|
||||
return new BaseInputConnection(this,false);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean onCheckIsTextEditor() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue