Jelajahi Sumber

added drag and drop file support

Nicolas Cannasse 7 tahun lalu
induk
melakukan
28353f5e2f
1 mengubah file dengan 10 tambahan dan 0 penghapusan
  1. 10 0
      hide/ui/Ide.hx

+ 10 - 0
hide/ui/Ide.hx

@@ -86,6 +86,16 @@ class Ide {
 		// handle cancel on type=file
 		// handle cancel on type=file
 		var body = window.window.document.body;
 		var body = window.window.document.body;
 		body.onfocus = function(_) haxe.Timer.delay(function() new Element(body).find("input[type=file]").change().remove(), 200);
 		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
 		// dispatch global keys based on mouse position
 		new Element(body).keydown(function(e) {
 		new Element(body).keydown(function(e) {