From 01a04c4d480f41973f6f26f501033e70de0d131d Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Fri, 9 Jun 2023 10:06:41 -0700 Subject: [PATCH] Clipboard: (windows/mac) fix issue where requesting text from clipboard ignores clipboard contents, if user last modified the clipboard before app startup --- src/lime/system/Clipboard.hx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lime/system/Clipboard.hx b/src/lime/system/Clipboard.hx index 6e7f71557..3bd98914b 100644 --- a/src/lime/system/Clipboard.hx +++ b/src/lime/system/Clipboard.hx @@ -20,6 +20,7 @@ class Clipboard public static var onUpdate = new EventVoid>(); 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;