Android: Enable selection in webkit
- by tacone
Hello, I'am looking for a way to have a webview content selectable in the very same way as the stock browser does.
user long presses the text
the whole word is selected
two pins appear at the word's boundary allowing the user to stretch/shrink the selection.
I should note that Dolphin HD shows exactly the same text select functionality as the default browser (same icons, animation, etc), so it really should be possible. But I can't figure out how.
Until now, all i found was this function, which kind of work, but doesn't allow the user to expand/shrink the selection.
public void selectAndCopyText()
{
try {
KeyEvent shiftPressEvent = new KeyEvent(0,0,KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_SHIFT_LEFT,0,0);
shiftPressEvent.dispatch(mWebView);
} catch (Exception e) {
throw new AssertionError(e);
}
}