Skip to content

Commit 1c298ec

Browse files
authored
Update NotifyDropTargetAction.md
1 parent b94a704 commit 1c298ec

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

specs/NotifyDropTargetAction.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,26 @@
1313

1414

1515
# Background
16-
This API will allow users to drop things such as images, text, and links into the WebView as part of a drag/drop operation.
17-
The reason that we need a separate API for this with composition hosting is because we don't have an HWND to call RegisterDragDrop on.
16+
These APIs will allow users to drop things such as images, text, and links into the WebView as part of a drag/drop operation.
17+
The reason that we need separate APIs for this with composition hosting is because we don't have an HWND to call RegisterDragDrop on.
1818
The hosting app needs to call RegisterDragDrop on the HWND that contains the WebView and implement IDropTarget so it can forward the
19-
calls (IDropTarget::DragEnter, DragMove, DragLeave, and Drop) to the WebView.
19+
calls (IDropTarget::DragEnter, DragMove, DragLeave, and Drop) to the WebView. Other UI frameworks have their own ways to register.
20+
For example, Xaml require setting event handler for DragEnter, DragOver, DragLeave, and Drop on the corresponding UIElement.
2021

21-
Additionally, the hosting app also needs to call into IDropTargetHelper before forwarding those calls to us as documented here:
22+
Additionally, for win32, the hosting app also needs to call into IDropTargetHelper before forwarding those calls to us as documented here:
2223
https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-idroptargethelper
2324

25+
For API reviewers, We want a unified API surface between COM and WinRT that works in both UWP and Win32.
26+
27+
We could have one API focusing on Win32 types and require the end dev to convert from UWP types to Win32 (which we've done).
28+
Or we could have one API focusing on UWP types and require the end dev to convert Win32 to UWP.
29+
Or we could have two sets of methods one for Win32 and one for UWP types.
30+
Or we could do (1) or (2) and provide a conversion function.
31+
Because the conversion is simple and we have a large Win32 user base we chose (1).
32+
2433

2534
# Description
26-
NotifyDropTargetAction is meant to provide a way for composition hosted WebViews to receive drop events as part of a drag/drop operation.
35+
DragEnter, DragOver, DragLeave, and Drop are functions meant to provide a way for composition hosted WebViews to receive drop events as part of a drag/drop operation.
2736
It is the hosting application's responsibility to call RegisterDragDrop (https://docs.microsoft.com/en-us/windows/win32/api/ole2/nf-ole2-registerdragdrop)
2837
on the HWND that contains any composition hosted WebViews and to implement IDropTarget(https://docs.microsoft.com/en-us/windows/win32/api/oleidl/nn-oleidl-idroptarget)
2938
to receive the corresponding drop events from Ole32:
@@ -33,9 +42,8 @@ to receive the corresponding drop events from Ole32:
3342
- IDropTarget::DragLeave
3443
- IDropTarget::Drop
3544

36-
NotifyDropTargetAction consolidates these four functions into one and the COREWEBVIEW2_DROP_TARGET_ACTION enum
37-
specifies which corresponding IDropTarget function was called.
38-
45+
For other UI frameworks such as Xaml, the hosting application would set event handlers for DragEnter, DragOver, DragLeave, and Drop
46+
on the UIElement that contains the WebView2 element.
3947

4048
# Examples
4149
## Win32
@@ -191,16 +199,6 @@ private uint ConvertDragDropModifiersToWin32KeyboardState(
191199

192200
# API Details
193201
## Win32
194-
```c++
195-
[v1_enum]
196-
typedef enum COREWEBVIEW2_DROP_TARGET_ACTION {
197-
COREWEBVIEW2_DRAG_ENTER,
198-
COREWEBVIEW2_DRAG_LEAVE,
199-
COREWEBVIEW2_DRAG_OVER,
200-
COREWEBVIEW2_DROP,
201-
} COREWEBVIEW2_DROP_TARGET_ACTION;
202-
```
203-
204202
```c++
205203
interface ICoreWebView2CompositionController2 : ICoreWebView2CompositionController {
206204
/// This set of APIs (DragEnter, DragLeave, DragOver, and Drop) will allow
@@ -289,6 +287,7 @@ namespace Microsoft.Web.WebView2.Core
289287
{
290288
public sealed class CoreWebView2CompositionController : CoreWebView2Controller, ICoreWebView2CompositionController2
291289
{
290+
// New APIs
292291
uint DragEnter(
293292
Windows.ApplicationModel.DataTransfer.DataPackage dataObject,
294293
uint keyState,

0 commit comments

Comments
 (0)