Closed DmitryBorodiy closed 4 years ago
WebView on WPF does not show contextual menus. And also, the contextual menu is not displayed when you press the right button on the text box. Please add a contextual menu like the old IE-based WebBrowser. That's a great idea. You also need to add the ability to disable and turn it on.
Will the contextual menu be implemented on WebView 2?
David Risney, can I take your contact email for support?
You can prevent and show a contextmenu from script:
document.documentElement.addEventListener("contextmenu", function (e) { showMyMenu(e); e.preventDefault() })
Can you set an example with the contextual menu in WebView? For C# WPF
I don't use C# or WPF, but basic principle is create JS, then PostMessage to .Net:
Sub BrowserCreated(sender As Object, e As EventArgs)
AddScriptToExecuteOnDocumentCreated("document.documentElement.addEventListener("contextmenu",function(e){window.chrome.webview.postMessage('contextmenu');e.preventDefault() }")
End Sub
Sub WebMessageRecieved(sender As Object, e As WebMessageReceivedEventArgs)
If e.WebMessageAsString="contextmenu" then
MyContextMenu.Show(WebView2, WebView2.PointToClient(Cursor.Position))
End If
How do I copy, cut, paste text from WebView through code?
As you can't say 'thank you', I won't answer any more of your posts. Basic stuff from about two years old.
Ok, thank you😁
EdgeHTML (WebView) developers, please add a contextual menu to your control. I assure you this is a great idea for WebView. Many .NET developers lack this. Through JS, this is not very convenient. Methods are also needed: Copy(), Paste (), Cut (). This will make your control really convenient. I just want to help make WebView better. Thank you😁
You can read about DOM APIs for interacting with the clipboard (and all other DOM APIs): https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard
I'll move your context menu feature request out into its own issue for WebView2. We have planned to look into such an API for WebView2.
The ability to customize the contextual menu is present in Chromium. You can use it in your control.
Why don't you integrate the context menu from Edge to WebView (EdgeHTML)?
Thank you in advance
Please add a contextual menu to WebView EdgeHTML.
Thank you for your understanding.
I'm really looking forward to the release of WebView 2 for .NET Framework WinForms and WPF, as my app is written on C#.
With Chromium I had a problem. I couldn't open a few windows with a Chromium control. I could only run one window with one control. I used the CefSharp library.
Will webView 2 be able to run multiple controls at once?
Will multitasking be implemented?
Thank you😊
Yes, you can run multiple WebView2 webviews at the same time.
When will WebView 2 work on the C#?
We're working on C# support for the first half of 2020 with a dev preview sometime earlier.
Thank you)
Will so contextual menu with buttons copy, cut, paste?
Will there be WebView.Copy(); , WebView.Paste(); , WebView.Cut(); methods?
It wouldn't be bad if Microsoft.Toolkit.Wpf.UI.Controls had a new TabView control.
return await myWebView.InvokeScriptAsync("eval", new string[] { "document.execCommand("copy");" });
Can I use this to copy text from WebView?
Thank you in advance
We'll likely have an API to allow customizing the context menu entries (providing your own, removing existing) and potentially also separately a mechanism to own drawing the context menu. I don't believe we will have cut/copy/paste methods on the WebView itself.
If you have feedback for Microsoft.Toolkit.Wpf.UI.Controls you may need to find their github project?
I'm not positive if you can use that to copy text in a WebView (EdgeHtml). There is an API CaptureSelectedContentToDataPackage that you might try out. Otherwise all you can do is inject script like what you're trying using MDN's description of interacting with the clipboard
I'll try to implement it.
How can I connect with those who work on the Microsoft.Toolkit.Wpf.UI.Controls library?
How do I get a screenshot of WebView (EdgeHTML) on WPF C#?
WebView.CapturePreviewToStream doesn't work on WPF.
What should I do?
Thank you in advance.
I also can't catch a right-click event on WebView.
The nuget package for Microsoft.Toolkit.Wpf.UI.Controls takes you to https://github.com/windows-toolkit/Microsoft.Toolkit.Win32/releases so maybe from there you can figure it out?
If CapturePreviewToStream isn't available then I don't know how to do that.
You should be able to use JavaScript to catch the right click in WebView1. See https://developer.mozilla.org/en-US/docs/Web/API/Element/contextmenu_event
Thank you for helping😁.
I try it.
I solved the problem with TabView. I found a FabTab library that helped me implement the tabs.
Will I be able to get a screenshot of the web page in WebView 2 on C#?
There is also a problem with opening local files, I can't open the file with absolute path. When will I be able to open files with absolute path in WebView on WPF apps?
Will WebView send visitation data and other confidential information to Microsoft?
How to optimize WebView(EdgeHTML) control? And how to clean the WebView(EdgeHTML) cache?
Thank you in advance
You can expect the same functionality in the WPF version of WebView as the Win32 version. We tentatively plan to release WebView for C# in Q3 2020.
WebView does send data to Microsoft in-line with the data collected by the browser. You can read more about it here: https://support.microsoft.com/en-us/help/4468242/microsoft-edge-browsing-data-and-privacy-microsoft-privacy
2.How to get a screenshot of the site with WebView (EdgeHTML) C# WPF.
3.How to open a local file with WebView(EdgeHTML) C# WPF.
Also, if you're not having a hard time, you can take a code sample. I also want to remind you that my project is running on WPF (.NET Framework) technology and using the C# language. I am grateful to the Edge team for their support in advance😁.
The text was translated using Microsoft Bing Translator.