Issue
I was able to get the selected text using the following method:
webview.evaluateJavascript("(function(){return window.getSelection().toString()})()",
new ValueCallback<String>()
{
@Override
public void onReceiveValue(String value)
{
selected = value;
Log.v(TAG, "SELECTION:" + value);
}
}
);
And I detect the first selection using when the motion event detected by the onTouchEvent
is ACTION_UP
.
webview.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
if(event.getAction() == MotionEvent.ACTION_UP)
{
//webview started selection a word
}
}
});
My problem is to be able to detect when the selection changes using the handlers. Unfortunately ACTION_MOVE
and ACTION_DOWN
are not getting called while changing the selection using the default selection handlers.
Kindly note that when I use the ActionMode CallBack
function, the default selection stops working.
Solution
Instead of trying to mange the touches try letting the system do it for you:
How to get the selected text of webview in ActionMode override
@Override
public void onReceiveValue(String value)
{
Log.v(TAG, "SELECTION:" + value);
}
with possibly.... selection change ? :)
Answered By - user1135300
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.