Skip to content

Commit fdd9511

Browse files
authored
Merge 10f32eb into 8ffd29f
2 parents 8ffd29f + 10f32eb commit fdd9511

File tree

11 files changed

+163
-2
lines changed

11 files changed

+163
-2
lines changed

CefSharp.Example/CefExample.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public static class CefExample
2424
public const string BasicSchemeTestUrl = BaseUrl + "/SchemeTest.html";
2525
public const string ResponseFilterTestUrl = BaseUrl + "/ResponseFilterTest.html";
2626
public const string DraggableRegionTestUrl = BaseUrl + "/DraggableRegionTest.html";
27+
public const string DragDropCursorsTestUrl = BaseUrl + "/DragDropCursorsTest.html";
2728
public const string CssAnimationTestUrl = BaseUrl + "/CssAnimationTest.html";
2829
public const string CdmSupportTestUrl = BaseUrl + "/CdmSupportTest.html";
2930
public const string TestResourceUrl = "http://test/resource/load";

CefSharp.Example/CefSharp.Example.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
<None Include="Resources\assets\js\shBrushJScript.js" />
153153
<Content Include="Resources\assets\js\shCore.js" />
154154
<Content Include="Resources\BindingTestSingle.html" />
155+
<Content Include="Resources\DragDropCursorsTest.html" />
155156
<Content Include="Resources\LegacyBindingTest.html" />
156157
<Content Include="Resources\CdmSupportTest.html" />
157158
<Content Include="Resources\CssAnimation.html" />

CefSharp.Example/CefSharpSchemeHandlerFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static CefSharpSchemeHandlerFactory()
4747
{ "/ScriptedMethodsTest.html", Resources.ScriptedMethodsTest },
4848
{ "/ResponseFilterTest.html", Resources.ResponseFilterTest },
4949
{ "/DraggableRegionTest.html", Resources.DraggableRegionTest },
50+
{ "/DragDropCursorsTest.html", Resources.DragDropCursorsTest },
5051
{ "/CssAnimationTest.html", Resources.CssAnimation },
5152
{ "/CdmSupportTest.html", Resources.CdmSupportTest },
5253
{ "/Recaptcha.html", Resources.Recaptcha },

CefSharp.Example/InMemorySchemeAndResourceHandlerFactory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ static InMemorySchemeAndResourceHandlerFactory()
4545
{ "/PopupTest.html", Resources.PopupTest },
4646
{ "/SchemeTest.html", Resources.SchemeTest },
4747
{ "/TooltipTest.html", Resources.TooltipTest },
48+
{ "/DragDropCursorsTest.html", Resources.DragDropCursorsTest },
4849
{ "/FramedWebGLTest.html", Resources.FramedWebGLTest },
4950
{ "/MultiBindingTest.html", Resources.MultiBindingTest },
5051
{ "/ScriptedMethodsTest.html", Resources.ScriptedMethodsTest },

CefSharp.Example/Properties/Resources.Designer.cs

Lines changed: 31 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CefSharp.Example/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@
133133
<data name="TooltipTest" type="System.Resources.ResXFileRef, System.Windows.Forms">
134134
<value>..\Resources\TooltipTest.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
135135
</data>
136+
<data name="DragDropCursorsTest" type="System.Resources.ResXFileRef, System.Windows.Forms">
137+
<value>..\Resources\DragDropCursorsTest.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
138+
</data>
136139
<data name="bootstrap_min_css" type="System.Resources.ResXFileRef, System.Windows.Forms">
137140
<value>..\Resources\bootstrap\bootstrap.min.css;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
138141
</data>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2+
<html>
3+
<head>
4+
<title>Drag&Drop Cursors Test</title>
5+
<style>
6+
.dropzone {
7+
width: 80px;
8+
height: 70px;
9+
padding: 10px;
10+
display: inline-block;
11+
border: 1px solid #aaaaaa;
12+
background: white;
13+
}
14+
15+
#drag {
16+
width: 200px;
17+
height: 50px;
18+
padding: 10px;
19+
border: 1px solid #aaaaaa;
20+
background: wheat;
21+
}
22+
</style>
23+
<script>
24+
function allowDrop(ev, effect) {
25+
ev.dataTransfer.dropEffect = effect;
26+
ev.preventDefault();
27+
}
28+
29+
function drag(ev) {
30+
ev.dataTransfer.setData("text", ev.target.id);
31+
}
32+
33+
function drop(ev) {
34+
ev.preventDefault();
35+
var data = ev.dataTransfer.getData("text");
36+
ev.target.appendChild(document.getElementById(data));
37+
}
38+
</script>
39+
</head>
40+
<body>
41+
<div class="dropzone" ondrop="drop(event)" ondragover="allowDrop(event, 'none')">None</div>
42+
<div class="dropzone" ondrop="drop(event)" ondragover="allowDrop(event, 'copy')">Copy</div>
43+
<div class="dropzone" ondrop="drop(event)" ondragover="allowDrop(event, 'move')">Move</div>
44+
<div class="dropzone" ondrop="drop(event)" ondragover="allowDrop(event, 'link')">Link</div>
45+
<br>
46+
<br>
47+
<div id="drag" draggable="true" ondragstart="drag(event)">Drag me over the drop zones</div>
48+
</body>
49+
</html>

CefSharp.Wpf.Example/MainWindow.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<MenuItem Header="_LegacyBinding Test" Command="controls:CefSharpCommands.OpenTabCommand" CommandParameter="{Binding Source={x:Static ex:CefExample.LegacyBindingTestUrl}}"/>
3030
<MenuItem Header="_List Plugins" Command="controls:CefSharpCommands.OpenTabCommand" CommandParameter="{Binding Source={x:Static ex:CefExample.PluginsTestUrl}}"/>
3131
<MenuItem Header="_Tooltip Test" Command="controls:CefSharpCommands.OpenTabCommand" CommandParameter="{Binding Source={x:Static ex:CefExample.TooltipTestUrl}}"/>
32+
<MenuItem Header="D_rag&amp;Drop Cursors Test" Command="controls:CefSharpCommands.OpenTabCommand" CommandParameter="{Binding Source={x:Static ex:CefExample.DragDropCursorsTestUrl}}"/>
3233
<MenuItem Header="_Popup Test" Command="controls:CefSharpCommands.OpenTabCommand" CommandParameter="{Binding Source={x:Static ex:CefExample.PopupParentUrl}}"/>
3334
<MenuItem Header="_Popup Test Custom Scheme" Command="controls:CefSharpCommands.OpenTabCommand" CommandParameter="{Binding Source={x:Static ex:CefExample.PopupTestUrl}}"/>
3435
<MenuItem Header="_Basic Scheme Test" Command="controls:CefSharpCommands.OpenTabCommand" CommandParameter="{Binding Source={x:Static ex:CefExample.BasicSchemeTestUrl}}"/>

CefSharp.Wpf/CefSharp.Wpf.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
</ItemGroup>
8080
<ItemGroup>
8181
<Compile Include="CefSettings.cs" />
82+
<Compile Include="DragCursorProvider.cs" />
8283
<Compile Include="Internals\MonitorInfo.cs" />
8384
<Compile Include="Internals\MonitorInfoEx.cs" />
8485
<Compile Include="Internals\RectStruct.cs" />

CefSharp.Wpf/ChromiumWebBrowser.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ private void NoInliningConstructor()
489489
DragOver += OnDragOver;
490490
DragLeave += OnDragLeave;
491491
Drop += OnDrop;
492+
GiveFeedback += OnGiveFeedback;
492493

493494
IsVisibleChanged += OnIsVisibleChanged;
494495

@@ -610,6 +611,7 @@ protected virtual void Dispose(bool isDisposing)
610611
DragOver -= OnDragOver;
611612
DragLeave -= OnDragLeave;
612613
Drop -= OnDrop;
614+
GiveFeedback -= OnGiveFeedback;
613615

614616
IsVisibleChanged -= OnIsVisibleChanged;
615617

@@ -787,7 +789,8 @@ void IRenderWebBrowser.UpdateDragCursor(DragOperationsMask operation)
787789
/// <param name="operation">describes the allowed operation (none, move, copy, link). </param>
788790
protected virtual void UpdateDragCursor(DragOperationsMask operation)
789791
{
790-
//TODO: Someone should implement this
792+
var dragCursor = DragCursorProvider.GetCursor(operation);
793+
UiThreadRunAsync(() => Mouse.SetCursor(dragCursor));
791794
}
792795

793796
/// <summary>
@@ -1531,6 +1534,16 @@ private void OnDragOver(object sender, DragEventArgs e)
15311534
}
15321535
}
15331536

1537+
/// <summary>
1538+
/// Handles the <see cref="E:GiveFeedback" /> event.
1539+
/// </summary>
1540+
/// <param name="sender">The sender.</param>
1541+
/// <param name="e">The <see cref="GiveFeedbackEventArgs"/> instance containing the event data.</param>
1542+
private void OnGiveFeedback(object sender, GiveFeedbackEventArgs e) {
1543+
/// prevent showing default cursor, the appropriate cursor will be set by <see cref=UpdateDragCursor />
1544+
e.Handled = true;
1545+
}
1546+
15341547
/// <summary>
15351548
/// Handles the <see cref="E:DragEnter" /> event.
15361549
/// </summary>

0 commit comments

Comments
 (0)