ncannasse 10 سال پیش
والد
کامیت
7942a671ee
2فایلهای تغییر یافته به همراه30 افزوده شده و 0 حذف شده
  1. 21 0
      h2d/comp/Input.hx
  2. 9 0
      hxd/System.hx

+ 21 - 0
h2d/comp/Input.hx

@@ -16,7 +16,9 @@ class Input extends Interactive {
 		input.cursor = TextInput;
 		cursor = new h2d.Bitmap(null, bg);
 		cursor.visible = false;
+		var ctrlDown = false;
 		input.onFocus = function(_) {
+			ctrlDown = false;
 			addClass(":focus");
 			cursor.visible = true;
 			onFocus();
@@ -54,6 +56,22 @@ class Input extends Interactive {
 				case Key.ENTER:
 					input.blur();
 					return;
+				case Key.CTRL:
+					ctrlDown = true;
+				}
+				if( ctrlDown ) {
+					switch( e.keyCode ) {
+					case "V".code:
+						var clip = hxd.System.getClipboard();
+						if( clip != "" ) {
+							clip = clip.split("\t").join(" ").split("\r\n").join(" ").split("\r").join(" ").split("\n").join(" ");
+							value = value.substr(0, cursorPos) + clip + value.substr(cursorPos);
+							cursorPos += clip.length;
+							onChange(value);
+						}
+					default:
+					}
+					return;
 				}
 				if( e.charCode != 0 ) {
 					value = value.substr(0, cursorPos) + String.fromCharCode(e.charCode) + value.substr(cursorPos);
@@ -62,6 +80,9 @@ class Input extends Interactive {
 				}
 			}
 		};
+		input.onKeyUp = function(e:hxd.Event) {
+			if( e.keyCode == Key.CTRL ) ctrlDown = false;
+		};
 		this.value = "";
 	}
 

+ 9 - 0
hxd/System.hx

@@ -148,6 +148,15 @@ class System {
 	}
 	#end
 
+	public static function getClipboard() : String {
+		#if flash
+		trace(flash.desktop.Clipboard.generalClipboard.getData(flash.desktop.ClipboardFormats.TEXT_FORMAT));
+		return flash.desktop.Clipboard.generalClipboard.getData(flash.desktop.ClipboardFormats.TEXT_FORMAT);
+		#else
+		return "";
+		#end
+	}
+
 	public static function exit() {
 		#if flash
 		if( isAir() ) {