class EE::Window::Clipboard¶
Overview¶
#include <clipboard.hpp> class Clipboard { public: // typedefs typedef std::vector<Uint8> Data; typedef std::function<const void*(const char*mimeType, size_t*size)> DataCallback; typedef std::function<void()> CleanupCallback; // construction virtual ~Clipboard(); // methods virtual std::string getText() = 0; virtual String getWideText() = 0; virtual void setText(const std::string& Text) = 0; EE::Window::Window* getWindow() const; virtual bool hasPrimarySelection() const; virtual std::string getPrimarySelectionText(); virtual void setPrimarySelectionText(const std::string& text); virtual bool setData(DataCallback callback, CleanupCallback cleanup, const std::vector<std::string>& mimeTypes); virtual bool clearData(); virtual Data getData(const std::string& mimeType); virtual std::vector<std::string> getMimeTypes(); virtual bool hasData(const std::string& mimeType) const; bool setMimeData(std::vector<std::pair<std::string, std::string>> dataByMimeType); std::string getDataString(const std::string& mimeType); static const std::vector<std::string>& getTextMimeTypes(); };
Detailed Documentation¶
Methods¶
virtual std::string getText() = 0
Returns:
The Clipboard Text if available
virtual String getWideText() = 0
Returns:
The Clipboard Text if available ( as String)
virtual void setText(const std::string& Text) = 0
Set the current clipboard text
EE::Window::Window* getWindow() const
Returns:
The parent window of the clipboard
virtual bool hasPrimarySelection() const
Returns:
True if primary selection is available
virtual std::string getPrimarySelectionText()
Returns:
The Clipboard Primary Selection Text if available
virtual void setPrimarySelectionText(const std::string& text)
Set the current clipboard primary selection text
virtual bool setData(DataCallback callback, CleanupCallback cleanup, const std::vector<std::string>& mimeTypes)
Offer non-text clipboard data in one or more MIME types. The data callback is invoked lazily when the operating system requests a format, and with a null MIME type when the offer is cleared or replaced. The returned data must remain valid until the cleanup callback is invoked. Only implemented by the SDL3 backend.
virtual bool clearData()
Clear all clipboard data. Only implemented by the SDL3 backend.
virtual Data getData(const std::string& mimeType)
Get clipboard data for a MIME type. Only implemented by the SDL3 backend.
virtual std::vector<std::string> getMimeTypes()
Returns:
The MIME types currently offered by the clipboard. SDL3 backend only.
virtual bool hasData(const std::string& mimeType) const
Returns:
Whether clipboard data is available for a MIME type. SDL3 backend only.
bool setMimeData(std::vector<std::pair<std::string, std::string>> dataByMimeType)
Offers fixed data in several MIME types, in order of preference: a convenience over setData() for content that is already known. The data is copied and kept until the offer is replaced or cleared. To keep the content pasteable as text, also offer it under getTextMimeTypes(). Only implemented by the SDL3 backend.
Returns:
False if the backend does not support clipboard data.
std::string getDataString(const std::string& mimeType)
Returns:
getData() as a string (empty if the MIME type is not available).
static const std::vector<std::string>& getTextMimeTypes()
Returns:
The MIME types that text is requested as across platforms (UTF-8 text first), for offers made with setData() / setMimeData() that must also be readable as text.