Skip to content

Commit

Permalink
feat(Clipboard): macOS support for Clear and Flush
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed May 19, 2020
1 parent 9b2deee commit 2e6932b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Uno.UWP/ApplicationModel/DataTransfer/Clipboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ namespace Windows.ApplicationModel.DataTransfer
public partial class Clipboard
{
private static object _syncLock = new object();
#if !__MACOS__
private static EventHandler<object> _contentChanged;
#endif

public static void Flush()
{
// Do nothing, data available automatically even after application closes.
}

#if !__MACOS__
public static event EventHandler<object> ContentChanged
{
add
Expand Down Expand Up @@ -45,6 +48,7 @@ private static void OnContentChanged()
{
_contentChanged?.Invoke(null, null);
}
#endif
}
}
#endif
8 changes: 7 additions & 1 deletion src/Uno.UWP/ApplicationModel/DataTransfer/Clipboard.macOS.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if __MACOS__
#if __MACOS__
using AppKit;

namespace Windows.ApplicationModel.DataTransfer
Expand All @@ -20,6 +20,12 @@ public static DataPackageView GetContent()
dataPackageView.SetText(clipboardText);
return dataPackageView;
}

public static void Clear()
{
var pasteboard = NSPasteboard.GeneralPasteboard;
pasteboard.ClearContents();
}
}
}
#endif

0 comments on commit 2e6932b

Please sign in to comment.