Compartir a través de


CoreWebView2CompositionController Class

Extends: CoreWebView2Controller

This class is an extension of the CoreWebView2Controller class to support visual hosting.

Summary

Members Description
Cursor The current cursor that WebView thinks it should be.
RootVisualTarget Gets or sets the root visual in the hosting app's visual tree.
DragEnter Call this method to inform the CoreWebView2CompositionController that a drag operation entered the WebView2.
DragLeave Call this method to inform the CoreWebView2CompositionController that a drag operation has left the WebView.
DragOver Call this method to inform the CoreWebView2CompositionController that a drag operation is moving over the WebView2.
Drop Call this method to inform the CoreWebView2CompositionController that an object is being dropped into the WebView2.
GetNonClientRegionAtPoint Call this method to perform hit-testing inside of your message loop when the message is WM_NCHITTEST.
QueryNonClientRegion This method retrieves the non-client regions on the page which corresponds to a given kind CoreWebView2NonClientRegionKind.
SendMouseInput Sends mouse input to the WebView.
SendPointerInput Sends pen or pointer input to the WebView.
CursorChanged The event is raised when WebView thinks the cursor should be changed.
NonClientRegionChanged This event is raised when elements on the page with "app-region" CSS property values corresponding to non-client regions change. Use the CoreWebView2NonClientRegionChangedEventArgs.RegionKind to see the kind of non-client region that changed.

Properties

Cursor

readonly CoreCursor Cursor

The current cursor that WebView thinks it should be.

RootVisualTarget

Object RootVisualTarget

Gets or sets the root visual in the hosting app's visual tree. This visual is where the WebView will connect its visual tree. The app uses this visual to position the WebView within the app. The app still needs to use the CoreWebView2Controller.Bounds property to size the WebView. The RootVisualTarget property can be an IDCompositionVisual or a Windows::UI::Composition::ContainerVisual. WebView will connect its visual tree to the provided visual before returning from the property setter. The app needs to commit on its device setting the RootVisualTarget property. The RootVisualTarget property supports being set to null to disconnect the WebView from the app's visual tree.

Methods

DragEnter

DataPackageOperation DragEnter(CoreDragInfo dragInfo, CoreDragUIOverride dragUIOverride)

Call this method to inform the CoreWebView2CompositionController that a drag operation entered the WebView2. Corresponds to the ICoreDropOperationTarget.EnterAsync method when performing a drag operation into the WebView.

DragLeave

void DragLeave()

Call this method to inform the CoreWebView2CompositionController that a drag operation has left the WebView. Corresponds to the ICoreDropOperationTarget.LeaveAsync method when performing a drag operation into the WebView.

DragOver

DataPackageOperation DragOver(CoreDragInfo dragInfo, CoreDragUIOverride dragUIOverride)

Call this method to inform the CoreWebView2CompositionController that a drag operation is moving over the WebView2. Corresponds to the ICoreDropOperationTarget.OverAsync method when performing a drag operation into the WebView.

Drop

DataPackageOperation Drop(CoreDragInfo dragInfo)

Call this method to inform the CoreWebView2CompositionController that an object is being dropped into the WebView2. Corresponds to the ICoreDropOperationTarget.DropAsync method when performing a drag operation into the WebView.

GetNonClientRegionAtPoint

CoreWebView2NonClientRegionKind GetNonClientRegionAtPoint(Point point)

Call this method to perform hit-testing inside of your message loop when the message is WM_NCHITTEST.

QueryNonClientRegion

IVectorView<Rect> QueryNonClientRegion(CoreWebView2NonClientRegionKind Kind)

This method retrieves the non-client regions on the page which corresponds to a given kind CoreWebView2NonClientRegionKind. This method can be used inside the CoreWebView2CompositionController.NonClientRegionChanged event handler to get the list of rects for the specific region that changed.

SendMouseInput

void SendMouseInput(CoreWebView2MouseEventKind eventKind, CoreWebView2MouseEventVirtualKeys virtualKeys, uint32_t mouseData, Point point)

Sends mouse input to the WebView. If eventKind is CoreWebView2MouseEventKind.HorizontalWheel or CoreWebView2MouseEventKind.Wheel, then mouseData specifies the amount of wheel movement. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. One wheel click is defined as WHEEL_DELTA, which is 120. If eventKind is CoreWebView2MouseEventKind.XButtonDoubleClick, CoreWebView2MouseEventKind.XButtonDown, or CoreWebView2MouseEventKind.XButtonUp, then mouseData specifies which X buttons were pressed or released. This value should be 1 if the first X button is pressed/released and 2 if the second X button is pressed/released. If eventKind is CoreWebView2MouseEventKind.Leave, then virtualKeys, mouseData, and point should all be zero. If eventKind is any other value, then mouseData should be zero. point is expected to be in the client coordinate space of the WebView. To track mouse events that start in the WebView and can potentially move outside of the WebView and host application, calling SetCapture and ReleaseCapture is recommended. To dismiss hover popups, it is also recommended to send CoreWebView2MouseEventKind.Leave messages.

SendPointerInput

void SendPointerInput(CoreWebView2PointerEventKind eventKind, CoreWebView2PointerInfo pointerInfo)

Sends pen or pointer input to the WebView. Accepts touch or pen pointer input of kinds defined in CoreWebView2PointerEventKind. Any pointer input from the system must be converted into a CoreWebView2PointerInfo first.

Events

CursorChanged

The event is raised when WebView thinks the cursor should be changed. For example, when the mouse cursor is currently the default cursor but is then moved over text, it may try to change to the IBeam cursor. It is expected for the developer to send CoreWebView2MouseEventKind.Leave messages (in addition to CoreWebView2MouseEventKind.Move messages) through CoreWebView2CompositionController.SendMouseInput. This is to ensure that the mouse is actually within the WebView that sends out CursorChanged events.

Type: TypedEventHandler<CoreWebView2CompositionController, Object>

NonClientRegionChanged

This event is raised when elements on the page with "app-region" CSS property values corresponding to non-client regions change. Use the CoreWebView2NonClientRegionChangedEventArgs.RegionKind to see the kind of non-client region that changed.

Type: TypedEventHandler<CoreWebView2CompositionController, CoreWebView2NonClientRegionChangedEventArgs>