Clipboard: (windows/mac) fix issue where requesting text from clipboard ignores clipboard contents, if user last modified the clipboard before app startup

This commit is contained in:
Josh Tynjala
2023-06-09 10:06:41 -07:00
parent aebf139dc7
commit 01a04c4d48

View File

@@ -20,6 +20,7 @@ class Clipboard
public static var onUpdate = new Event<Void->Void>();
public static var text(get, set):String;
private static var _text:String;
@:noCompletion private static var __updated = false;
private static function __update():Void
{
@@ -42,6 +43,7 @@ class Clipboard
_text = FlashClipboard.generalClipboard.getData(TEXT_FORMAT);
}
#end
__updated = true;
if (_text != cacheText)
{
@@ -68,6 +70,14 @@ class Clipboard
// formatting will unavoidably be lost.)
set_text(_text);
}
#elseif (windows || mac)
if (!__updated)
{
// Lime listens for clipboard updates automatically, but if the
// clipboard has never been updated since before the app started,
// we need to populate the initial contents manually
__update();
}
#end
return _text;