Преглед изворни кода

Add clipboard support in hl 1.12 (#10320)

Aleksandr Kuzmenko пре 4 година
родитељ
комит
96e6846812
2 измењених фајлова са 34 додато и 0 уклоњено
  1. 1 0
      extra/CHANGES.txt
  2. 33 0
      std/hl/UI.hx

+ 1 - 0
extra/CHANGES.txt

@@ -4,6 +4,7 @@
 
 	js : fixed IntMap for keys greater than 2^31 (#10316)
 	js : workaround to fix sourcemaps on Firefox in Windows (#10217)
+	hl : add clipboard support in hl 1.12 (#10320)
 
 2021-07-01 4.2.3:
 

+ 33 - 0
std/hl/UI.hx

@@ -214,4 +214,37 @@ class UI {
 	static function _chooseFile(forSave:Bool, obj:Dynamic):hl.Bytes {
 		return null;
 	}
+	
+	#if (hl_ver >= version("1.12.0"))
+	public static function setClipboardText(text:String):Bool {
+		if(text == null)
+			return false;
+		return @:privateAccess _setClipboardText(text.toUtf8());
+	}
+
+	@:hlNative("?ui", "ui_set_clipboard_text")
+	static function _setClipboardText(text:hl.Bytes):Bool {
+		return false;
+	}
+
+	public static function getClipboardText():String {
+		var t = _getClipboardText();
+		if( t == null )
+			return null;
+		return @:privateAccess String.fromUTF8(t);
+	}
+
+	@:hlNative("?ui", "ui_get_clipboard_text")
+	static function _getClipboardText():hl.Bytes {
+		return null;
+	}
+	#else
+	public static function setClipboardText(text:String):Bool {
+		return false;
+	}
+	public static function getClipboardText():String {
+		return null;
+	}
+	#end
+	
 }