MCPcopy Index your code
hub / github.com/csev/py4e / onDrop

Function onDrop

tools/pythonauto/static/codemirrorepl/codemirrorepl.js:660–698  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

658 selectWordAt(start);
659 }
660 function onDrop(e) {
661 if (options.onDragEvent && options.onDragEvent(instance, addStop(e))) return;
662 e.preventDefault();
663 var pos = posFromMouse(e, true), files = e.dataTransfer.files;
664 if (!pos || options.readOnly) return;
665 if (files && files.length && window.FileReader && window.File) {
666 function loadFile(file, i) {
667 var reader = new FileReader;
668 reader.onload = function() {
669 text[i] = reader.result;
670 if (++read == n) {
671 pos = clipPos(pos);
672 operation(function() {
673 var end = replaceRange(text.join(""), pos, pos);
674 setSelectionUser(pos, end);
675 })();
676 }
677 };
678 reader.readAsText(file);
679 }
680 var n = files.length, text = Array(n), read = 0;
681 for (var i = 0; i < n; ++i) loadFile(files[i], i);
682 }
683 else {
684 try {
685 var text = e.dataTransfer.getData("Text");
686 if (text) {
687 compoundChange(function() {
688 var curFrom = sel.from, curTo = sel.to;
689 setSelectionUser(pos, pos);
690 if (draggingText) replaceRange("", curFrom, curTo);
691 replaceSelection(text);
692 focusInput();
693 });
694 }
695 }
696 catch(e){}
697 }
698 }
699 function onDragStart(e) {
700 var txt = getSelection();
701 e.dataTransfer.setData("Text", txt);

Callers

nothing calls this directly

Calls 8

compoundChangeFunction · 0.85
setSelectionUserFunction · 0.85
replaceSelectionFunction · 0.85
addStopFunction · 0.70
posFromMouseFunction · 0.70
loadFileFunction · 0.70
replaceRangeFunction · 0.70
focusInputFunction · 0.70

Tested by

no test coverage detected