docs
Docs
C++ API
C API
Search API
Ctrl K
2.0
2.0
latest
1.4
Ultralight C++ API
2.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
Clipboard.h
Go to the documentation of this file.
1
///
2
/// Copyright (C) 2026 Ultralight, Inc. All rights reserved.
3
/// A license is required for commercial use. https://ultralig.ht
4
///
5
#pragma once
6
#include <
Ultralight/ClipboardData.h
>
7
#include <
Ultralight/Defines.h
>
8
9
namespace
ultralight
{
10
11
///
12
/// User-defined clipboard interface.
13
///
14
/// The library uses this to read and write data to the system's clipboard, as whole
15
/// multi-format payloads (see ClipboardData).
16
///
17
/// A platform-specific implementation of Clipboard that cuts, copies, and pastes to the OS
18
/// clipboard is provided for you when you call App::Create().
19
///
20
/// If you are using Renderer::Create() instead of App::Create(), you will need to provide your own
21
/// implementation of this. @see Platform::set_clipboard().
22
///
23
/// ## Types the Library Uses
24
///
25
/// The library currently reads and writes these well-known types: `text/plain`, `text/html`,
26
/// and `text/uri-list`. Your implementation should map each type it supports to the matching OS
27
/// clipboard format and simply skip types it doesn't recognize (a backend that only supports
28
/// text is fine-- write the `text/plain` entry and ignore the rest).
29
///
30
/// @note The library only calls these methods on the thread you created the Renderer or App on,
31
/// so your implementation doesn't need to be safe to call from more than one thread.
32
///
33
class
UExport
Clipboard
{
34
public
:
35
virtual
~Clipboard
();
36
37
///
38
/// Clear the clipboard.
39
///
40
/// The library doesn't call this today (a copy replaces the previous contents through
41
/// Write()); it exists so applications sharing your Clipboard instance can clear the OS
42
/// clipboard through the same interface.
43
///
44
virtual
void
Clear
() = 0;
45
46
///
47
/// Read the clipboard's current contents.
48
///
49
/// This is called when the library wants to paste from the OS clipboard. You should return one
50
/// entry per format you can read (at minimum the `text/plain` entry, if the clipboard holds
51
/// text).
52
///
53
/// @return Returns the clipboard contents. Returning a null pointer is equivalent to
54
/// returning an empty payload (the library treats both as an empty clipboard).
55
///
56
virtual
RefPtr<ClipboardData>
Read
() = 0;
57
58
///
59
/// Write a payload to the clipboard, replacing its previous contents.
60
///
61
/// This is called when the library wants to copy to the OS clipboard. All of the payload's
62
/// entries should be written in one atomic clipboard transaction (on Windows: one
63
/// OpenClipboard / EmptyClipboard / SetClipboardData per entry / CloseClipboard cycle), so a
64
/// multi-format copy can never partially replace an earlier write.
65
///
66
/// @param data The payload to write (never null; may hold types you don't support, which you
67
/// should skip).
68
///
69
virtual
void
Write
(
RefPtr<ClipboardData>
data) = 0;
70
};
71
72
}
// namespace ultralight
ClipboardData.h
UExport
#define UExport
Definition
Exports.h:22
Defines.h
ultralight::Clipboard
User-defined clipboard interface.
Definition
Clipboard.h:33
ultralight::Clipboard::Write
virtual void Write(RefPtr< ClipboardData > data)=0
Write a payload to the clipboard, replacing its previous contents.
ultralight::Clipboard::~Clipboard
virtual ~Clipboard()
ultralight::Clipboard::Clear
virtual void Clear()=0
Clear the clipboard.
ultralight::Clipboard::Read
virtual RefPtr< ClipboardData > Read()=0
Read the clipboard's current contents.
ultralight::RefPtr
A nullable smart pointer.
Definition
RefPtr.h:126
ultralight
Root namespace for every public Ultralight type, function, and enumeration.
Ultralight
platform
Clipboard.h
Docs
C++ API
C API
Version
2.0
2.0
latest
1.4