SDL_GetClipboardData(3)

πŸ’– SDL_GetClipboardData(3) πŸ’–

okay bestie, so this one lives in the SDL3 FUNCTIONS part of the manual, and it's literally your backstage pass to whatever the clipboard is holding rn. Let's get into it ✨


🌸 NAME 🌸

SDL_GetClipboardData β€” grab the data sitting on the clipboard for a mime type you pick πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_clipboard.h>

void * SDL_GetClipboardData(const char *mime_type, size_t *size);

✨ DESCRIPTION ✨

So like, the size of text data does not include the terminator, but the text is guaranteed to be null-terminated. Both things are true at once, she contains multitudes πŸ’…


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • mime_type β€” the mime type you wanna read off the clipboard. pick your fighter 🫢
  • size β€” a pointer that gets filled in with the length of the returned data. she's an out-param, she's doing her job πŸ“

πŸ”₯ RETURN VALUE πŸ”₯

Returns the retrieved data buffer, or NULL on failure 😭 β€” in that case call SDL_GetError() for more info, she'll tell you what went wrong.

⚠️ no cap: you must free that buffer with SDL_free() once you're done with it. don't just leave it sitting there, that's not main character energy, that's a leak πŸ’€

πŸ’œ THREAD SAFETY πŸ’œ

This function should only be called on the main thread. do not be texting the clipboard from a side thread bestie, she will not answer πŸ™ˆ


🌈 AVAILABILITY 🌈

This function is available since SDL 3.2.0. vintage but make it fresh ✨


🫢 SEE ALSO 🫢

iykyk, go read those next, they're the whole friend group πŸ’–


mwah okay that's the whole page!! brought to you by the fine folks at Simple Directmedia Layer, from SDL 3.4.18, and yes this specific page is SDL_GetClipboardData(3) πŸ¦‹ go get that clipboard data queen πŸ‘‘

πŸ“¦ where this page comes from