Skip to content

Commit

Permalink
DYN-5408 Disabling unnecessary settings webview2 (#13555)
Browse files Browse the repository at this point in the history
* disabling settings

* Enabling scroll in document browser and library

* assigning comments

* Enabling dev tools
  • Loading branch information
filipeotero authored Nov 23, 2022
1 parent bf29f56 commit 8d09124
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ async void InitializeAsync()
}));

this.documentationBrowser.CoreWebView2.WebMessageReceived += CoreWebView2OnWebMessageReceived;
this.documentationBrowser.CoreWebView2.Settings.IsZoomControlEnabled = true;
this.documentationBrowser.CoreWebView2.Settings.AreDevToolsEnabled = true;
}

private void CoreWebView2OnWebMessageReceived(object sender, CoreWebView2WebMessageReceivedEventArgs e)
Expand Down
3 changes: 3 additions & 0 deletions src/DynamoCoreWpf/Utilities/ResourceUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,9 @@ internal static async Task<object> ExecuteJSFunction(UIElement MainWindow, HostC
// Context menu disabled
webBrowserComponent.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;
webBrowserComponent.NavigateToString(bodyHtmlPage);

webBrowserComponent.CoreWebView2.Settings.IsZoomControlEnabled = false;
webBrowserComponent.CoreWebView2.Settings.IsPinchZoomEnabled = false;
}
catch (Exception ex)
{
Expand Down
3 changes: 3 additions & 0 deletions src/DynamoCoreWpf/Views/SplashScreen/SplashScreen.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ protected override async void OnContentRendered(EventArgs e)
await webView.EnsureCoreWebView2Async();
// Context menu disabled
webView.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;
// Zoom control disabled
webView.CoreWebView2.Settings.IsZoomControlEnabled = false;

var assembly = Assembly.GetExecutingAssembly();

using (Stream stream = assembly.GetManifestResourceStream(htmlEmbeddedFile))
Expand Down
3 changes: 2 additions & 1 deletion src/LibraryViewExtensionWebView2/LibraryViewController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -266,6 +266,7 @@ async void InitializeAsync()
twoWayScriptingObject = new ScriptingObject(this);
//register the interop object into the browser.
this.browser.CoreWebView2.AddHostObjectToScript("bridgeTwoWay", twoWayScriptingObject);
browser.CoreWebView2.Settings.IsZoomControlEnabled = true;
}

private void CoreWebView2_WebMessageReceived(object sender, CoreWebView2WebMessageReceivedEventArgs args)
Expand Down
2 changes: 2 additions & 0 deletions src/Notifications/NotificationCenterController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ private void WebView_CoreWebView2InitializationCompleted(object sender, Microsof
// Hosts an object that will expose the properties and methods to be called from the javascript side
notificationUIPopup.webView.CoreWebView2.AddHostObjectToScript("scriptObject",
new ScriptObject(OnMarkAllAsRead));

notificationUIPopup.webView.CoreWebView2.Settings.IsZoomControlEnabled = false;
}
}

Expand Down

0 comments on commit 8d09124

Please sign in to comment.