瀏覽代碼

added drag and drop file support

Nicolas Cannasse 7 年之前
父節點
當前提交
28353f5e2f
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10 0
      hide/ui/Ide.hx

+ 10 - 0
hide/ui/Ide.hx

@@ -86,6 +86,16 @@ class Ide {
 		// handle cancel on type=file
 		var body = window.window.document.body;
 		body.onfocus = function(_) haxe.Timer.delay(function() new Element(body).find("input[type=file]").change().remove(), 200);
+		body.ondragover = function(e:js.html.DragEvent) {
+			e.preventDefault();
+			return false;
+		};
+		body.ondrop = function(e:js.html.DragEvent) {
+			for( f in e.dataTransfer.files )
+				openFile(Reflect.field(f,"path"));
+			e.preventDefault();
+			return false;
+		}
 
 		// dispatch global keys based on mouse position
 		new Element(body).keydown(function(e) {