public interface IClipboardThe system clipboard.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Synchronous, which is a decision and not an oversight. Reading a browser's clipboard is asynchronous and gated on a user gesture, so an async API would look like it worked there and would still return nothing when called from anywhere but a paste handler. Making that the shape of the interface would push a lie into every caller. The web implementation instead serves what the last paste event delivered, which is the only thing a browser will ever let it have, and the desktop implementations do the straightforward thing.
Reads can fail for reasons that are nobody's fault: another application owns the clipboard and has stopped responding, the format is not what was asked for, or — on a headless platform — there is no clipboard at all. Hence the Try shape throughout; none of these are exceptional.
Fields and properties (2)
bool HasTextWhether the clipboard currently holds text.
bool HasImageWhether the clipboard currently holds an image.
Methods (7)
bool TryGetText(out string? text)Reads the clipboard's text.
bool SetText(string text)Puts text on the clipboard.
bool TryGetImage(out ClipboardImage image)Reads the clipboard's image.
bool SetImage(in ClipboardImage image)Puts an image on the clipboard.
bool TryGetData(string format, out ReadOnlyMemory<byte> data)Reads a custom format's bytes.
bool SetData(string format, ReadOnlySpan<byte> data)Puts a custom format's bytes on the clipboard.
void Clear()Empties the clipboard, if the platform allows it.
Used by (14)
- DesktopClipboardVixen.Platform.Desktop
- DesktopPlatformVixen.Platform.Desktop
- DesktopPlatformTestsVixen.Platform.Desktop.Tests
- HeadlessClipboardVixen.Platform.Headless
- HeadlessLifecycleTestsVixen.Platform.Headless.Tests
- HeadlessPlatformVixen.Platform.Headless
- IPlatformVixen.Platform
- LinuxClipboardVixen.Platform.Linux
- MacOSClipboardVixen.Platform.MacOS
- NothingClipboardVixen.Platform.MacOS.Tests
- NothingClipboardVixen.Platform.Desktop.Tests
- PlatformServicesVixen.Platform
- RecordingSupplementVixen.Platform.Desktop.Tests
- WindowsClipboardVixen.Platform.Windows