Skip to content

Commit

Permalink
Work around fact that FF doesn't set modifiers on drop events
Browse files Browse the repository at this point in the history
Store the modifier in the original mouse event to choose between
move and copy drags.

Issue codemirror#2556
  • Loading branch information
marijnh committed Jun 7, 2016
1 parent 2543f79 commit eabf5b5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -3660,6 +3660,7 @@
// Let the drag handler handle this.
if (webkit) display.scroller.draggable = true;
cm.state.draggingText = dragEnd;
dragEnd.copy = mac ? e.altKey : e.ctrlKey
// IE's approach to draggable
if (display.scroller.dragDrop) display.scroller.dragDrop();
on(document, "mouseup", dragEnd);
Expand Down Expand Up @@ -3890,7 +3891,7 @@
try {
var text = e.dataTransfer.getData("Text");
if (text) {
if (cm.state.draggingText && !(mac ? e.altKey : e.ctrlKey))
if (cm.state.draggingText && !cm.state.draggingText.copy)
var selected = cm.listSelections();
setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
if (selected) for (var i = 0; i < selected.length; ++i)
Expand Down

0 comments on commit eabf5b5

Please sign in to comment.