Android: Enable selection in webkit

Posted by tacone on Stack Overflow See other posts from Stack Overflow or by tacone
Published on 2010-06-13T12:03:55Z Indexed on 2010/06/13 12:12 UTC
Read the original article Hit count: 351

Filed under:
|
|
|

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);
    }
} 

© Stack Overflow or respective owner

Related posts about android

Related posts about text