English 中文(简体)
• 如何在网上填写文件,2
原标题:How to make ontounchend in document return true in WebView2

In WebView2 browser, I want to move things with finger. But it does not support ontouchxxx(ontouchstart, ontouchend). In other word, "ontouchend" in document returns false.

I tried various ways as followings but it doesn t work.

webView2 = new Microsoft.Web.WebView2.WinForms.WebView2();
  1. setTouchEmulationEnabled
    await webView2.EnsureCoreWebView2Async(null);
    if (webView2.CoreWebView2 != null)
    {
        webView2.CoreWebView2.CallDevToolsProtocolMethodAsync("Emulation.setEmitTouchEventsForMouse", "{ enabled : true }");
    }
  1. --enable-features=msWebView2EnableDraggableRegions
    string arg = @"--enable-features=""msWebView2EnableDraggableRegions""";
    var opts = new CoreWebView2EnvironmentOptions { AdditionalBrowserArguments = arg };
    var webView2Environment = await CoreWebView2Environment.CreateAsync(null, null, opts);
    await webView21.EnsureCoreWebView2Async(webView2Environment);
  1. IsSwipeNavigationEnabled
    await webView2.EnsureCoreWebView2Async(null);
    if (webView2.CoreWebView2 != null)
    {
        webView2.CoreWebView2.Settings.IsSwipeNavigationEnabled = true;
    }
  1. Change UserAgent like iPad emulator of chrome,edge which return true for "ontouchend" in document
     await webView2.EnsureCoreWebView2Async(null);
     if (webView2.CoreWebView2 != null)
     {
         webView2.CoreWebView2.Settings.UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15";
     }
问题回答

我认为,这是按设计的,因为本份标书只使用触动装置,如果你想在纸浆上实施这种功能,我就认为你可能需要使用一些其他假想。





相关问题
how to programmatically fake a touch event to a UIButton?

I m writing some unit tests and, because of the nature of this particular app, it s important that I get as high up the UI chain as possible. So, what I d like to do is programmatically trigger a ...

AFOpenFlow touchevent Image

does anybody know a solution that i could implement at this code, that the pictures could be touched and an event will be started? - (void)viewDidLoad { [super viewDidLoad]; // loading ...

png transparency registering touch event iphone?

I have three png s "320 x 480px" that I am loading into separate UIImageViews. The png s names are body, mouth, hat. By stacking the images on top of each other I create a character whose body parts ...

How to filter touch events for a UIScrollView?

I have a view that displays a PDF. It should be zoomable, so I also created a UIScrollView, and in its delegate I implemented viewForZoomingInScrollView to return the PDF view. So far so good. ...

Get touch events in a UITextView

Apple does not provide touch event handling for UITextView. The project I m developing includes notes that can be readable and editable, and I am using a UITextView. Please help me with this problem --...

热门标签