Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drag and drop in WPF #171

Closed
mwisnicki opened this issue Sep 16, 2013 · 22 comments
Closed

Drag and drop in WPF #171

mwisnicki opened this issue Sep 16, 2013 · 22 comments

Comments

@mwisnicki
Copy link
Contributor

Right now it's not supported.

See upstream bug - it also applies to CEF1.

@jornh jornh added the upstream label Apr 10, 2014
@mikecousins
Copy link

It looks like the upstream bug has now been fixed. Is anybody able to pull in the latest Chromium?

@peters
Copy link
Contributor

peters commented Sep 25, 2014

@mikecousins

install-package cefsharp.wpf -version 33.0.0-pre0 -source https://odinkapital.myget.org/F/cefsharp/

@amaitland Is working on merging in support for 1750 in cefsharp/cef-binary#11. He thinks it will be available something around next week :)

@peters
Copy link
Contributor

peters commented Sep 25, 2014

This version is based on the latest stable release of CEF3 (3.1750.1738)

@mikecousins
Copy link

Thanks for the quick response.

This version is quite different! I notice that the browser object has been renamed from WebView to ChromiumWebBrowser. When I try to run it I got an error saying that I had to run Cef.Initialize() first. I added CefSharp.Cef.Initialize(); and now I'm getting a null reference exception when I run it.

System.NullReferenceException was unhandled
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=CefSharp.Wpf
StackTrace:
at CefSharp.Wpf.ChromiumWebBrowser.<CefSharp.Internals.IRenderWebBrowser.SetBitmap>b__2f(InteropBitmap bitmap)
at CefSharp.Wpf.ChromiumWebBrowser.SetBitmapHelper(BitmapInfo bitmapInfo, InteropBitmap bitmap, Action`1 imageSourceSetter)
at CefSharp.Wpf.ChromiumWebBrowser.CefSharp.Internals.IRenderWebBrowser.SetBitmap(BitmapInfo bitmapInfo)
at CefSharp.Wpf.ChromiumWebBrowser.<>c__DisplayClassf.<CefSharp.Internals.IRenderWebBrowser.InvokeRenderAsync>b__e()
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at BrightsquidDesktop.App.Main() in c:\Users\Mike\Documents\Visual Studio 2013\Projects\BrightsquidDesktop\BrightsquidDesktop\obj\x86\Debug\App.g.cs:line 0
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

@jornh
Copy link
Contributor

jornh commented Sep 25, 2014

What version are you coming from, CefSharp1 something?

If so, then oh yes under the hood (the upstream CEF and Chromium) it's quite different - multi-process etc.- for further discussion and info pointers see #394 (comment)

Also CefSharp3 compared to CefSharp1 itself now has switched from being primarily written in C++ to the majority now being C# for better hackability to hopefully more .NET developers.

@mikecousins
Copy link

Thanks. I got it working now with the latest version. I still don't seem to be able to handle drag and drop though.

This is my code and the drag and drop demo does not work:

    public MainWindow()
    {
        InitializeComponent();
        var settings = new CefSettings { PackLoadingDisabled = true };

        if (Cef.Initialize(settings))
        {
            var browser = new ChromiumWebBrowser();
            browser.AllowDrop = true;
            browser.Address = "http://html5demos.com/drag";
            //browser.Address = "http://www.html5test.com";
            MainGrid.Children.Add(browser);
        }
    }

Or did your comment from above mean that we still need to wait for @amaitland to check in his latest code and then update from that Nuget source to a later version?

@jornh
Copy link
Contributor

jornh commented Sep 26, 2014

See https://code.google.com/p/chromiumembedded/issues/detail?id=1032#c23

Yes, it's fixed upstream but not before the 1916 branch, which still hasn't got an official release, only nightly builds. So that we're about to merge 1750 doesn't do anything for drag n drop.

Maybe you can work with Aaron in the Google Group who is trying to get to a running 2062 branch?

@amaitland amaitland removed cef1 upstream These issues require fixing in the Chromium Embedded Framework(CEF) or Chromium. labels Oct 13, 2014
@amaitland amaitland added this to the 35.0.0 milestone Oct 13, 2014
@amaitland
Copy link
Member

@peters has kindly done a lot of work in getting a working build of 2062 going, as per #506

It's a little bit of work to build manually at the moment. Hopefully in the next few weeks/ months we'll have an experimental build available.

@jornh
Copy link
Contributor

jornh commented Oct 26, 2014

With #532 on its way onto https://github.com/cefsharp/CefSharp/tree/cef/2062 It's less work to try out with http://html5demos.com/drag# now.

I just did and it's still not working.

I think the CEF bug to follow (and vote for by giving it a ⭐) now is https://code.google.com/p/chromiumembedded/issues/detail?id=1364&q=label%3AOSR

@amaitland amaitland modified the milestones: 39.0.0, 37.0.0 Nov 12, 2014
@amaitland
Copy link
Member

From what I can tell we need to implement the appropriate OSR Drag methods, the cefclient example would be a starting reference point.

Methods are here https://bitbucket.org/chromiumembedded/branches-2171-cef3/src/10a08114355a477bfb4e29e06755763ad61b458e/include/cef_browser.h?at=master#cl-581

@amaitland amaitland modified the milestones: 3000, 39.0.0 Dec 17, 2014
@Bodekaer
Copy link
Contributor

Bodekaer commented Jan 6, 2015

Did anyone look into this?
We'll need this for an upcoming release this month, so I could give it a go if no one is already on it.

@amaitland
Copy link
Member

@Bodekaer Go for it 👍

@Bodekaer
Copy link
Contributor

Bodekaer commented Jan 7, 2015

I'm on it :)

@Bodekaer
Copy link
Contributor

Bodekaer commented Jan 7, 2015

Done :)

@jornh
Copy link
Contributor

jornh commented Jan 7, 2015

Awesome-sovs! (Whish I had time to take it for a spin ... but sadly not today 😢)

@Bodekaer
Copy link
Contributor

Bodekaer commented Jan 7, 2015

Hehe :) It works really nicely. And opens up so many new possibilities here, which is amazing.

@myrnazhou, FYI we have drag drop now. Might be useful for native image drag drop at some point (low priority though).

@amaitland
Copy link
Member

Drag and Drop support has been implemented with #756, it's not 100% feature complete. I'm happy that it covers your typical usage scenario so I'm going to close this.

Great work @Bodekaer 👍

@amaitland amaitland modified the milestones: 39.0.0, 3000 Feb 3, 2015
@Bodekaer
Copy link
Contributor

Bodekaer commented Feb 3, 2015

Thanks a bunch. Happy to help.

Yeah, the primary thing that is missing is the ability to drag e.g. image/text out of the browser.
You can drag anything into the browser atm. E.g. dropping files/images into the browser.

If anyone wants to implement the former, please just let me know and I can help direct to the relevant code and documentation files.

@ralphmayr
Copy link
Contributor

Hi @Bodekaer! Could you provide some pointers to what would be necessary to get drag and drop out of and within the browser working? (So that for example http://html5demos.com/drag would work in CefShrp.Wpf)
Thanks!

@Bodekaer
Copy link
Contributor

Hey @ralphmayr,
Yes definitely. Would very much like to see this added as well.
I'd recommend checking out the "drag" related issues in CEF3, and then find the relevant revision which adds support for this:
https://code.google.com/p/chromiumembedded/issues/list?can=1&q=drag&colspec=ID+Type+Status+Priority+Milestone+Owner+Summary&cells=tiles

E.g. this issue might provide the relevant input (although related to CEF1 I believe):
https://code.google.com/p/chromiumembedded/issues/detail?id=140&can=1&q=drag

With that, you'll probably see that we need to implement a few C++ methods to support the CEF3 API for dragging within/out of the browser.
Once you find out what/where to add this, I can help with further directions if needed.
Usually it's fairly straightforward to implement the API support in CefSharp once we know what to actually do :)

@amaitland
Copy link
Member

The API docs are also quite handy http://magpcss.org/ceforum/apidocs3/index-all.html

@amaitland
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants