Boscop / web-view

Rust bindings for webview, a tiny cross-platform library to render web-based GUIs for desktop applications
MIT License
1.92k stars 175 forks source link

File Drag & Drop Support? #80

Open hyunh90 opened 5 years ago

hyunh90 commented 5 years ago

I am using this crate via neutrino for a Windows-specific desktop app and in need of file drag & drop support. I don't know much about WinAPI stuff, but looked some things up: can it be as easy as implementing UI_GetDropTarget() function?

hyunh90 commented 5 years ago

I found a related discussion Boscop/web-view#64. People smarter than me (😂) are already taking care of that, thus I am going to change this issue to a feature request.

richardhozak commented 5 years ago

Hi, it would definitely need to be implemented in all three platforms we support. I've considered that maybe we could switch to winit for windowing, so we do not have to maintain separate windowing code but even winit does not have drag & drop implemented (see rust-windowing/winit#720). It will probably be difficult to get right for all the platforms, but maybe we can start with Windows as a prototype first?

EDIT: Oh, it seems that winit has some basic drop file support.

hyunh90 commented 5 years ago

I cannot promise anything, but I can definitely start poking OLE API around for drag & drop support. (Maybe we can even use com-rs for this?)

richardhozak commented 5 years ago

Is there any advantage in using com-rs instead of using winapi-rs directly? But sure, use whatever you want, write it in Rust, write it in C, whatever suits you, we can iterate on that after we've got something working :).

richardhozak commented 4 years ago

I investigated more and we would most certainly need to use com-rs because winapi-rs does not have the required interfaces implemented, there are PRs to add many remaining interfaces we need such as IOleObject, but if we use com-rs we can define them ourselves, instead of waiting for them to be merged into winapi-rs (they sit there for quite some time).

PfisterFactor commented 4 years ago

Has there been any progress on this issue? Or perhaps a workaround for a MacOS platform?

FreeMasen commented 4 years ago

What is the advantage of implementing this in webview instead of pointing users to the js api designed to handle this?

https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/File_drag_and_drop

PfisterFactor commented 4 years ago

@FreeMasen I was under the impression that the javascript drag and drop api does not give you the full path name of the file and needs to be implemented in webview. see the issue in the webview repository.

FreeMasen commented 4 years ago

That is correct you cannot get the true file path, however you can get the bytes and the file name which could be passed through the existing eventing system.

PfisterFactor commented 4 years ago

My application needs to listen for file system events on the file dragged into the application, so direct access to the full path is needed. So I still think that this would be a useful feature to implement within Webview rather than just the JavaScript api. There might be some way to implement file system notifications within JavaScript, but it seems a hacky workaround.