@@ -30,6 +30,9 @@ When set to `FALSE`, then all non-client region support will be disabled.
3030* Web pages will not be able to use the ` app-region ` CSS style.
3131
3232# Examples
33+ This example enables non-client region support for all pages on www.microsoft.com .
34+ Pages on other origins will not be trusted to use this feature.
35+
3336``` cpp
3437ScenarioNonClientRegionSupport::ScenarioNonClientRegionSupport (AppWindow* appWindow)
3538 : m_appWindow(appWindow), m_webView(appWindow->GetWebView())
@@ -41,7 +44,7 @@ ScenarioNonClientRegionSupport::ScenarioNonClientRegionSupport(AppWindow* appWin
4144 ICoreWebView2* sender,
4245 ICoreWebView2NavigationStartingEventArgs* args) -> HRESULT
4346 {
44- static const PCWSTR url_compare_example = L"www.microsoft.com";
47+ static const PCWSTR allowedHostName = L"www.microsoft.com";
4548 wil::unique_cotaskmem_string uri;
4649 CHECK_FAILURE(args->get_Uri(&uri));
4750 wil::unique_bstr domain = GetDomainOfUri(uri.get());
@@ -55,12 +58,12 @@ ScenarioNonClientRegionSupport::ScenarioNonClientRegionSupport(AppWindow* appWin
5558 BOOL enabled;
5659 CHECK_FAILURE(coreWebView2Settings12->get_IsNonClientRegionSupportEnabled(&enabled));
5760
58- if (wcscmp(domain.get(), url_compare_example ) == 0 && !enabled)
61+ if (wcscmp(domain.get(), allowedHostName ) == 0 && !enabled)
5962 {
6063 CHECK_FAILURE(
6164 coreWebView2Settings12->put_IsNonClientRegionSupportEnabled(TRUE));
6265 }
63- else if (wcscmp(domain.get(), url_compare_example ) != 0 && enabled)
66+ else if (wcscmp(domain.get(), allowedHostName ) != 0 && enabled)
6467 {
6568 CHECK_FAILURE(
6669 coreWebView2Settings12->put_IsNonClientRegionSupportEnabled(FALSE));
@@ -73,8 +76,11 @@ ScenarioNonClientRegionSupport::ScenarioNonClientRegionSupport(AppWindow* appWin
7376```
7477
7578```c#
76- private WebView2 webView;
77- webView.CoreWebView2.NavigationStarting += SetNonClientRegionSupport;
79+ public MainWindow()
80+ {
81+ InitializeComponent();
82+ webView.NavigationStarting += SetNonClientRegionSupport;
83+ }
7884
7985private void SetNonClientRegionSupport(CoreWebView2 sender, CoreWebView2NavigationStartingEventArgs args)
8086{
@@ -94,6 +100,23 @@ private void SetNonClientRegionSupport(CoreWebView2 sender, CoreWebView2Navigati
94100 }
95101}
96102```
103+ ## Declaring Non-client App Regions
104+ Non-client regions are HTML elements that are marked with the css style ` app-region ` .
105+ * Draggable regions can be declared through the values ` drag ` or ` no-drag ` .
106+ * ` app-region: drag ` will support [ draggable region functionality] ( #description ) for the html element.
107+ * ` app-region: no-drag ` will change cursor to I-bar, with text highlighting enabled.
108+ Elements with this style will not support draggable region functionality.
109+ ``` html
110+ <!DOCTYPE html>
111+ <body >
112+ <div style =" app-region :drag" >Drag Region</h1 >
113+ </div >
114+ <div >
115+ <h1 style =" app-region :no-drag" >No-drag Region</h1 >
116+ </div >
117+ </body >
118+ <html >
119+ ```
97120
98121# Remarks
99122If the feature flag (` msWebView2EnableDraggableRegions ` ) is used to enable draggable regions in
@@ -104,16 +127,14 @@ additional browser arguments, draggable region support will remain enabled even
104127# API Notes
105128See [ API Details] ( #api-details ) section below for API reference.
106129
107- ## Declaring Non-client App Regions
108- Non-client regions are HTML elements that are marked with the css style ` app-region ` .
109- * Draggable regions can be declared through the values ` drag ` or ` no-drag ` .
130+
110131
111132# API Details
112133``` cpp
113134// / This is the ICoreWebView2Settings Staging interface.
114135[uuid(436CA5E2-2D50-43C7-9735 -E760F299439E), object, pointer_default(unique)]
115136interface ICoreWebView2Settings12 : ICoreWebView2Settings11 {
116- /// ` IsNonClientRegionSupportEnabled ` property enables web pages to use the
137+ /// The ` IsNonClientRegionSupportEnabled ` property enables web pages to use the
117138 /// ` app-region ` CSS style. Disabling/Enabling the ` IsNonClientRegionSupportEnabled `
118139 /// takes effect after the next navigation. Defaults to ` FALSE ` .
119140 ///
@@ -133,6 +154,18 @@ interface ICoreWebView2Settings12 : ICoreWebView2Settings11 {
133154 /// Set the IsNonClientRegionSupportEnabled property
134155 [ propput] HRESULT IsNonClientRegionSupportEnabled([ in] BOOL enabled);
135156}
157+
158+ ```c#
159+ namespace Microsoft .Web.WebView2.Core
160+ {
161+ runtimeclass CoreWebView2Settings
162+ {
163+ [interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2Settings12")]
164+ {
165+ Boolean IsNonClientRegionSupportEnabled { get; set; };
166+ }
167+ }
168+ }
136169```
137170
138171# Appendix
0 commit comments