Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cann't Delete image when click backspace on soft-keyboard on Android4.4 #51

Open
ChenJian345 opened this issue Apr 8, 2016 · 15 comments

Comments

@ChenJian345
Copy link

Using this, Cannot delete image in the editor, Android 4.4 devices.

@TakWolf
Copy link

TakWolf commented Apr 13, 2016

I have the same problem

@onion4
Copy link

onion4 commented May 8, 2016

@viviwen123 When I use your solution(Override deleteSurroundingText method),can delete image success,but cann't insert characters.I need your help.

@qiuqiutang
Copy link

@onion4 Do you solve this problem? I have the same problem.

@zhi-guan
Copy link

zhi-guan commented Jun 8, 2016

I have the same problem
##I refer to http:https://stackoverflow.com/questions/14560344/android-backspace-in-webview-baseinputconnection

then I make the following changes:

Override onCreateInputConnection in RichEditor.java
@OverRide
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
return new FixInputConnection(super.onCreateInputConnection(outAttrs),true);
}

###and create new InputConnection like this

@SuppressLint("NewApi")
public class FixInputConnection extends InputConnectionWrapper {

public FixInputConnection(InputConnection target, boolean mutable) {
    super(target, mutable);
}
@Override
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
    // magic: in latest Android, deleteSurroundingText(1, 0) will be called for backspace
    if (beforeLength == 1 && afterLength == 0) {
        // backspace
        return super.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL))
                && super.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DEL));
    }
    return super.deleteSurroundingText(beforeLength, afterLength);
}

}

@wangyiwy
Copy link

@onion4 哥们我也遇到你这个问题了 可以删除图片 不能输入字符 最后咋解决的呢

@pangxinlong
Copy link

pangxinlong commented Oct 13, 2016

I refer to http:https://stackoverflow.com/questions/16499178/cant-get-backspace-to-work-in-codemirror-under-phonegap-on-android-4-x

1:Override onCreateInputConnection in RichEditor.java
@OverRide
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
MyCustomInputConnection connection = new MyCustomInputConnection(this, false);
return connection;
}

2:Custom InputConnection:
public class MyCustomInputConnection extends BaseInputConnection{

public MyCustomInputConnection(View targetView, boolean fullEditor) {
    super(targetView, fullEditor);
}

@Override
public boolean deleteSurroundingText(int beforeLength, int afterLength) {       
    // magic: in latest Android, deleteSurroundingText(1, 0) will be called for backspace
    if (beforeLength == 1 && afterLength == 0) {
        // backspace
        return super.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL))
            && super.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DEL));
    }

    return super.deleteSurroundingText(beforeLength, afterLength);
}

}

@freestyletime
Copy link

@pangxinlong But cant input some charactors... such as CHINESE language~

@wuzheng4android
Copy link

@viviwen123 it not work can you tell me version of x5?

@freestyletime
Copy link

@viviwen123 No, its not work.

@2ndtonone
Copy link

@viviwen123 its not work...

@qiaop
Copy link

qiaop commented Jan 6, 2017

Anybody resolved this problem ?

@wuzheng4android
Copy link

use tencent x5

@freestyletime
Copy link

@wuzheng4android Hi man... Are u sure? doesnt work on it.

@tpnet
Copy link

tpnet commented Jan 20, 2018

@freestyletime tencent x5 can resolved this problem, You don't have to override onCreateInputConnection after use x5。。。 doesnt work to you,This may be that you have not initialized tencent x5 success,,,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests