@@ -108,7 +108,10 @@ public class ChromiumWebBrowser : Control, IRenderWebBrowser, IWpfWebBrowser
108108 /// we can reuse the drag data provided from CEF
109109 /// </summary>
110110 private IDragData currentDragData ;
111-
111+ /// <summary>
112+ /// Keep the current drag&drop effects to return the appropriate effects on drag over.
113+ /// </summary>
114+ private DragDropEffects currentDragDropEffects ;
112115 /// <summary>
113116 /// A flag that indicates whether or not the designer is active
114117 /// NOTE: Needs to be static for OnApplicationExit
@@ -761,14 +764,14 @@ bool IRenderWebBrowser.StartDragging(IDragData dragData, DragOperationsMask allo
761764 if ( browser != null )
762765 {
763766 //DoDragDrop will fire DragEnter event
764- var result = DragDrop . DoDragDrop ( this , dataObject , GetDragEffects ( allowedOps ) ) ;
767+ var result = DragDrop . DoDragDrop ( this , dataObject , allowedOps . GetDragEffects ( ) ) ;
765768
766769 //DragData was stored so when DoDragDrop fires DragEnter we reuse a clone of the IDragData provided here
767770 currentDragData = null ;
768771
769772 //If result == DragDropEffects.None then we'll send DragOperationsMask.None
770773 //effectively cancelling the drag operation
771- browser . GetHost ( ) . DragSourceEndedAt ( x , y , GetDragOperationsMask ( result ) ) ;
774+ browser . GetHost ( ) . DragSourceEndedAt ( x , y , result . GetDragOperationsMask ( ) ) ;
772775 browser . GetHost ( ) . DragSourceSystemDragEnded ( ) ;
773776 }
774777 } ) ;
@@ -780,14 +783,14 @@ void IRenderWebBrowser.UpdateDragCursor(DragOperationsMask operation)
780783 {
781784 UpdateDragCursor ( operation ) ;
782785 }
783-
786+
784787 /// <summary>
785788 /// Called when the web view wants to update the mouse cursor during a drag & drop operation.
786789 /// </summary>
787790 /// <param name="operation">describes the allowed operation (none, move, copy, link). </param>
788791 protected virtual void UpdateDragCursor ( DragOperationsMask operation )
789792 {
790- //TODO: Someone should implement this
793+ currentDragDropEffects = operation . GetDragEffects ( ) ;
791794 }
792795
793796 /// <summary>
@@ -1498,7 +1501,7 @@ private void OnDrop(object sender, DragEventArgs e)
14981501 if ( browser != null )
14991502 {
15001503 var mouseEvent = GetMouseEvent ( e ) ;
1501- var effect = GetDragOperationsMask ( e . AllowedEffects ) ;
1504+ var effect = e . AllowedEffects . GetDragOperationsMask ( ) ;
15021505
15031506 browser . GetHost ( ) . DragTargetDragOver ( mouseEvent , effect ) ;
15041507 browser . GetHost ( ) . DragTargetDragDrop ( mouseEvent ) ;
@@ -1527,8 +1530,10 @@ private void OnDragOver(object sender, DragEventArgs e)
15271530 {
15281531 if ( browser != null )
15291532 {
1530- browser . GetHost ( ) . DragTargetDragOver ( GetMouseEvent ( e ) , GetDragOperationsMask ( e . AllowedEffects ) ) ;
1533+ browser . GetHost ( ) . DragTargetDragOver ( GetMouseEvent ( e ) , e . AllowedEffects . GetDragOperationsMask ( ) ) ;
15311534 }
1535+ e . Effects = currentDragDropEffects ;
1536+ e . Handled = true ;
15321537 }
15331538
15341539 /// <summary>
@@ -1541,7 +1546,7 @@ private void OnDragEnter(object sender, DragEventArgs e)
15411546 if ( browser != null )
15421547 {
15431548 var mouseEvent = GetMouseEvent ( e ) ;
1544- var effect = GetDragOperationsMask ( e . AllowedEffects ) ;
1549+ var effect = e . AllowedEffects . GetDragOperationsMask ( ) ;
15451550
15461551 //DoDragDrop will fire this handler for internally sourced Drag/Drop operations
15471552 //we use the existing IDragData (cloned copy)
@@ -1552,62 +1557,6 @@ private void OnDragEnter(object sender, DragEventArgs e)
15521557 }
15531558 }
15541559
1555- /// <summary>
1556- /// Converts .NET drag drop effects to CEF Drag Operations
1557- /// </summary>
1558- /// <param name="dragDropEffects">The drag drop effects.</param>
1559- /// <returns>DragOperationsMask.</returns>
1560- /// s
1561- private static DragOperationsMask GetDragOperationsMask ( DragDropEffects dragDropEffects )
1562- {
1563- var operations = DragOperationsMask . None ;
1564-
1565- if ( dragDropEffects . HasFlag ( DragDropEffects . All ) )
1566- {
1567- operations |= DragOperationsMask . Every ;
1568- }
1569- if ( dragDropEffects . HasFlag ( DragDropEffects . Copy ) )
1570- {
1571- operations |= DragOperationsMask . Copy ;
1572- }
1573- if ( dragDropEffects . HasFlag ( DragDropEffects . Move ) )
1574- {
1575- operations |= DragOperationsMask . Move ;
1576- }
1577- if ( dragDropEffects . HasFlag ( DragDropEffects . Link ) )
1578- {
1579- operations |= DragOperationsMask . Link ;
1580- }
1581-
1582- return operations ;
1583- }
1584-
1585- /// <summary>
1586- /// Gets the drag effects.
1587- /// </summary>
1588- /// <param name="mask">The mask.</param>
1589- /// <returns>DragDropEffects.</returns>
1590- private static DragDropEffects GetDragEffects ( DragOperationsMask mask )
1591- {
1592- if ( ( mask & DragOperationsMask . Every ) == DragOperationsMask . Every )
1593- {
1594- return DragDropEffects . All ;
1595- }
1596- if ( ( mask & DragOperationsMask . Copy ) == DragOperationsMask . Copy )
1597- {
1598- return DragDropEffects . Copy ;
1599- }
1600- if ( ( mask & DragOperationsMask . Move ) == DragOperationsMask . Move )
1601- {
1602- return DragDropEffects . Move ;
1603- }
1604- if ( ( mask & DragOperationsMask . Link ) == DragOperationsMask . Link )
1605- {
1606- return DragDropEffects . Link ;
1607- }
1608- return DragDropEffects . None ;
1609- }
1610-
16111560 /// <summary>
16121561 /// PresentationSource changed handler.
16131562 /// </summary>
0 commit comments