1

I'm having a heckuva time trying to find a way to use javascript or css (not Java) to prevent Android devices from showing the pop up dialog when long-pressing on an html element like an image or anchor in a web page.

I'm trying to make a carousel and if I hold the left or right arrow down on my carousel, a window pops up asking me to open in a new tab, save the image, etc. I can do this easily enough on iOS/Safari with a css rule.

Screen shot of the dialog I'm trying to suppress

Thanks in advance.

mrbinky3000
  • 4,055
  • 8
  • 43
  • 54

1 Answers1

0

how are you setting your setOnLongClickListener and onTouch?

make sure it's similar to this

setOnLongClickListener(new View.OnLongClickListener() {

    public boolean onLongClick(View view) {

      activity.openContextMenu(view);  

     return true;  // avoid extra click events

    }

});

setOnTouch(new View.OnTouchListener(){

  public boolean onTouch(View v, MotionEvent e){

    switch(e.getAction & MotionEvent.ACTION_MASK){

      // do drag/gesture processing. 

    }

// you MUST return false for ACTION_DOWN and ACTION_UP, for long click to work
// you can return true for ACTION_MOVEs that you consume. 
// DOWN/UP are needed by the long click timer.
// if you want, you can consume the UP if you have made a drag - so that after 
// a long drag, no long-click is generated.

    return false;

  }

});

setLongClickable(true);

code curtosy of Sanjay Manohar Detect touch press vs long press vs movement?

Community
  • 1
  • 1
jos
  • 431
  • 2
  • 9