I am using btwebview to get text selection and handle it. The problem is when I use longPress with gestureDetector the default selection is also being launched, if I override onTouchEvent and return true, the problem is solved but I cannot click on any button or highlighted link on the webview, so I cannot access footnotes or videos inserted in the webview and shouldOverrideUrlLoading stops getting called.
public void init(Context context) {
System.out.println("BTWebview init");
this.context = context;
this.getSettings().setJavaScriptEnabled(true);
gestureScanner = new GestureDetector(this);
this.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
System.out.println("event "+event.toString() );
return gestureScanner.onTouchEvent(event);
}
});
setInitialScale(100);
addJavascriptInterface(new MyJavaScriptInterface(), "HTMLOUT");
}
@Override
public boolean onTouchEvent(MotionEvent event) {
System.out.print("on touch event "+ event.toString());
return true;
}
@Override
public void onLongPress(MotionEvent e) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
System.out.println("gesture listener onLongPress");
mSelection = true;
if(!this.isInSelectionMode()){
System.out.println("onLongClick in selection mode");
mSelection = true;
}
this.loadUrl("javascript:android.selection.longTouch();");
mScrolling = true;
System.out.println("onLongClick");
}