Return nil if clipboard does not contain any text

This commit is contained in:
Alessandro Proto 2023-02-18 20:33:25 +01:00
parent ac9081cf89
commit 001ce2f626

View file

@ -110,7 +110,7 @@ public class Machine : IComponent
if (!L.IsNoneOrNil(1)) if (!L.IsNoneOrNil(1))
{ {
var newTitle = L.CheckString(1); var newTitle = L.CheckString(1);
if (string.IsNullOrEmpty(newTitle)) if (string.IsNullOrEmpty(newTitle))
{ {
newTitle = "Capy64 " + Capy64.Version; newTitle = "Capy64 " + Capy64.Version;
@ -130,7 +130,10 @@ public class Machine : IComponent
{ {
var L = Lua.FromIntPtr(state); var L = Lua.FromIntPtr(state);
L.PushString(SDL.GetClipboardText()); if (SDL.HasClipboardText())
L.PushString(SDL.GetClipboardText());
else
L.PushNil();
return 1; return 1;
} }