sdlGetClipboardData function
Get the data from clipboard for a given mime type.
The size of text data does not include the terminator, but the text is guaranteed to be null terminated.
\param mime_type the mime type to read from the clipboard. \param size a pointer filled in with the length of the returned data. \returns the retrieved data buffer or NULL on failure; call SDL_GetError() for more information. This should be freed with SDL_free() when it is no longer needed.
\threadsafety This function should only be called on the main thread.
\since This function is available since SDL 3.1.3.
\sa SDL_HasClipboardData \sa SDL_SetClipboardData
extern SDL_DECLSPEC void * SDLCALL SDL_GetClipboardData(const char *mime_type, size_t *size)
Implementation
Pointer<NativeType> sdlGetClipboardData(
String? mimeType, Pointer<Uint32> size) {
final sdlGetClipboardDataLookupFunction = libSdl3.lookupFunction<
Pointer<NativeType> Function(
Pointer<Utf8> mimeType, Pointer<Uint32> size),
Pointer<NativeType> Function(Pointer<Utf8> mimeType,
Pointer<Uint32> size)>('SDL_GetClipboardData');
final mimeTypePointer = mimeType != null ? mimeType.toNativeUtf8() : nullptr;
final result = sdlGetClipboardDataLookupFunction(mimeTypePointer, size);
calloc.free(mimeTypePointer);
return result;
}