Disable Chrome paste menu on text inputs while on a touch screen
Asked Answered
W

1

8

How to disable this annoying contextmenu in chrome while on a touch screen. This pops up on selection/on long tap of any input while i have some text copied.

enter image description here

Am developing an app using CEFSharp (Chromium Embedded Framework) and its going to be deployed on touch screen on windows 8 machine. am using a on screen keyboard(http://mottie.github.io/Keyboard/) for entering text in input fields.

I have tried

            $('input').bind('copy paste contextmenu', function (e) {
                e.preventDefault();
                e.stopPropagation();
            });

this disables the pasting but the menu still shows up. how do i get rid of this menu? how best to approch this: CSS , Javascript or through chrome command line arguments (http://peter.sh/experiments/chromium-command-line-switches/) ?

Wilbourn answered 25/6, 2015 at 22:19 Comment(0)
S
1

i know you said JS / CSS, but this worked for me

var browser = new ChromiumWebBrowser("http://www.afrobotics.co.za")
{
  Dock = DockStyle.Fill,
  DragHandler = new DragHandler(),
  MenuHandler = new ContextHandler()
};

// 
public class ContextHandler : IMenuHandler
{
    public bool OnBeforeContextMenu(IWebBrowser browser, IContextMenuParams parameters)
    {
        return false;
    }
}

public class DragHandler : IDragHandler
{
    public bool OnDragEnter(IWebBrowser browser, IDragData dragData, DragOperationsMask mask)
    {
        return true;
    }
}

Stillhunt answered 7/7, 2015 at 9:25 Comment(6)
Did this work? it doesn't appear to work for me (although I have since upgraded to cefsharp 43.0.0.0). The IMenuHandler signature is different for OnBeforeContextMenu in this new version. You can't return false.Cyrillus
Use model.Clear(); instead of returning false in 43.0.0Calque
I was already doing that, I have successfully squashed the right click context menu, but this copy and paste overlay is still showing.Cyrillus
Any luck with this? same issue here.Monolingual
I'm looking for a solution as well, any news?La
try the command line switch --disable-javascript-dom-paste. but be careful unfortunately, --use-views seems to overwrite it.Puce

© 2022 - 2024 — McMap. All rights reserved.