简体   繁体   English

是否有可能通过CSS或JavaScript在Android浏览器中隐藏“长按”(又称“长按”)弹出对话框

[英]Is it possible to suppress the “Long Hold” (aka “long press”) pop-up dialog on Android browsers via CSS or JavaScript

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. 我正忙着尝试寻找一种方法,当长按html元素(例如图像或网页锚点)时,使用javascriptcss (不是Java)来防止Android设备显示弹出对话框。

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. 我正在尝试制作旋转木马,如果我按住旋转木马上的向左或向右箭头,则会弹出一个窗口,要求我在新标签页中打开,保存图像等。我可以在iOS /带有CSS规则的Safari。

我试图隐藏的对话框的屏幕截图

Thanks in advance. 提前致谢。

how are you setting your setOnLongClickListener and onTouch? 您如何设置setOnLongClickListener和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? Sanjay Manohar的代码曲线检测触摸触摸vs长按vs运动?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM