SDL_CLIPBOARDDATACALLBACK(3type)
π SDL_ClipboardDataCallback(3type) π
okay bestie, welcome to the SDL3 DATATYPES corner of the manual, where we meet a lil function-pointer diva called SDL_ClipboardDataCallback. she's the callback the OS hits up when somebody wants data for a specific mime-type. she serves. π
β¨ NAME β¨
SDL_ClipboardDataCallback β the callback function that gets called when the OS asks for the data of a specific mime-type. it's giving "on-demand snack delivery." π
π¦ SYNOPSIS π¦
#include <SDL3/SDL_clipboard.h>
typedef const void *(SDLCALL *SDL_ClipboardDataCallback)(void *userdata, const char *mime_type, size_t *size);
look at that signature. gorgeous. no notes. πΈ
π DESCRIPTION π
so here's the tea, bestie: this callback gets called with NULL as the mime_type when the clipboard is cleared or when new data is set. yes, NULL β that's the "hey nothing to see here, we're resetting" signal, don't panic.
also, plot twist: the clipboard gets cleared automatically in SDL_Quit(). she cleans up after herself. main character behavior, fr fr. β¨
π FUNCTION PARAMETERS π
userdataβ a pointer to the provided user data. your lil bag of stuff you handed over earlier. π«Άmime_typeβ the requested mime-type. the vibe being asked for.sizeβ a pointer that you fill in with the length of the returned data. don't forget her, she matters. π
π RETURN VALUE π
you return a pointer to the data for the provided mime-type. simple. iconic.
but here's the important part, no cap: if you return NULL, or if you set the length to 0, that causes zero length data to be sent to the "receiver" β and that receiver should be able to handle this. so like, don't be weird about it, it's a valid thing to do. π
and listen closely: the returned data will not be freed. like, at all. so it needs to be retained and dealt with internally. that's your problem now, bestie. keep it alive, manage it yourself, she's not doing it for you. π
β AVAILABILITY β
this function is available since SDL 3.2.0. so if you're on something older, that's a vibe check failure, sorry. π
π SEE ALSO π
SDL_SetClipboardData(3)β go read her next, she's the one who sets all this up. iykyk. π₯
and that's the whole page, bestie!! written up by the lovely folks at Simple Directmedia Layer, straight from SDL 3.4.18 β mwah, sending you kisses, go slay some clipboard code π§ππ
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms