Skip to content

Commit 50ed2b1

Browse files
committed
Added support for drag & drop from input fields
There was a problem with the previous implementation. It worked correctly for many use cases: - Dragging from a web app to a WPF control. - Dragging from a WPF control to a web app. - Dragging _html content_ from a web app to an input field **But**: when dragging text from one input field to another, the text would vanish (!) when you drop it. We debugged this here quite extensively. It turned out that if you have _set_ the `FragmentHtml` (even though you've set it to an empty string), it behaves like this. The solution is to avoid setting it if it is empty.
1 parent 0c3427f commit 50ed2b1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

CefSharp.Wpf/Internals/WpfExtensions.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
//
33
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
44

5+
using CefSharp.Internals;
6+
using System;
57
using System.IO;
68
using System.Text;
79
using System.Windows;
810
using System.Windows.Input;
9-
using CefSharp.Internals;
1011

1112
namespace CefSharp.Wpf.Internals
1213
{
@@ -115,7 +116,12 @@ public static CefDragDataWrapper GetDragDataWrapper(this DragEventArgs e)
115116
if (dragData.IsFragment)
116117
{
117118
dragData.FragmentText = (string)e.Data.GetData(DataFormats.Text);
118-
dragData.FragmentHtml = (string)e.Data.GetData(DataFormats.Html);
119+
120+
var htmlData = (string)e.Data.GetData(DataFormats.Html);
121+
if (htmlData != String.Empty)
122+
{
123+
dragData.FragmentHtml = htmlData;
124+
}
119125
}
120126

121127
return dragData;

0 commit comments

Comments
 (0)