You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem
Right now, to start a file drag you call WebContents.startDrag({ file:<path>, icon:<path> }). This will spawn the following DataTransfer object:
The issue is the effectAllowed, which when set to 'copyLink' will not allow dragging and dropping files from the electron BrowserWindow to say Discord as they only allow dropped items with the 'move' effect from what I can see.
Solution
I propose allowing either changing the default from 'copyLink' to 'copyMove', OR allowing users to pass the drop effect as an argument to WebContents.startDrag.
int item;
if (!item.Get("dropType", &item)) {
item = <some default drop type value, like ui::DragDropTypes.DRAG_COPY | ui::DragDropTypes.DRAG_LINK as it was previously>
}
👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.
@mattetti initially implemented the WebContents.startDrag function over two years ago (from #4622) @zcbenz seem to have worked on it too
Any of you know if the drop types can be changed from copyLink?
Problem
Right now, to start a file drag you call
WebContents.startDrag({ file:<path>, icon:<path> })
. This will spawn the following DataTransfer object:with
FileList
containing the proper file(s).The issue is the
effectAllowed
, which when set to'copyLink'
will not allow dragging and dropping files from the electron BrowserWindow to say Discord as they only allow dropped items with the 'move' effect from what I can see.Solution
I propose allowing either changing the default from 'copyLink' to 'copyMove', OR allowing users to pass the drop effect as an argument to
WebContents.startDrag
.File changes
drag_utils_views.cc (Line 20) - add argument for
DragFileItems
to accept a drop type (should be an int AFAIK, the ChromiumDragOperation
s are defined here).drag_utils_views.cc (Line 45) -
ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK
changed to a variable passed to the function.drag_utils.h (Line 18) - add argument for
DragFileItems
to accept a drop type.drag_util_mac.mm (Line 28) - may need to add argument to
DragFileItems
to accept a drop type too for compatibility with MACOSX. (I did not see how the drag type could be changed for osx, if they even use drag types the way windows does.)atom_api_web_contents.cc (Line 1736) - get the drop type from
item
likeatom_api_web_contents.cc (Line 1754) - pass argument for drop type.
Outcome
Example usage of WebContents.startDrag could now be
The text was updated successfully, but these errors were encountered: