SDL_SetTrayEntryCallback(3)

πŸ’– SDL_SetTrayEntryCallback β€” the SDL3 functions girlies know πŸ’–

okay so bestie, welcome to SDL_SetTrayEntryCallback(3), a page from the SDL3 FUNCTIONS collection. sit down, grab a strawberry πŸ“, and let's talk about making your system tray entries actually do something when someone clicks them, because an icon that does nothing is giving NPC energy and we don't do that here.


✨ NAME ✨

SDL_SetTrayEntryCallback β€” sets a callback to be invoked when the entry is selected.

like literally. you pick the entry, you hand it a function, and boom πŸ’₯ β€” when someone selects that entry, your callback gets called. it's giving "main character gets a spotlight" energy.


✨ SYNOPSIS ✨

#include <SDL3/SDL_tray.h>

void SDL_SetTrayEntryCallback(SDL_TrayEntry *entry, SDL_TrayCallback callback, void *userdata);

no cap, that's the whole vibe. three arguments, returns nothing, changes everything 🫢


✨ FUNCTION PARAMETERS ✨

  • entry β€” the entry to be updated. this is the tray entry you're blessing with new behaviour, the glow-up recipient ✨
  • callback β€” a callback to be invoked when the entry is selected. this is the function that gets the party started when someone picks that entry πŸ’…
  • userdata β€” an optional pointer to pass extra data to the callback when it will be invoked. it's optional, so if you don't need to hand your callback any extra lil goodies, that's totally fine, pass what you gotta pass πŸŽ€

✨ THREAD SAFETY ✨

⚠️ okay important one, bestie: this function should be called on the thread that created the tray.

like. the tray's thread. the one that birthed it. don't be calling this from some random other thread and expect sunshine and rainbows, because that is not the vibe. keep it in the family, okay? 😭


✨ AVAILABILITY ✨

this function is available since SDL 3.2.0. so if you're on something older, it's giving "not me being left on read" β€” you simply don't have it yet πŸ™ˆ


✨ SEE ALSO ✨

go read those too, they're iconic in their own right πŸ‘‘


and that's the whole page, bestie!! you now know how to give a tray entry a callback and make it feel seen. slay. πŸ’…βœ¨

mwah πŸ’– this was brought to you by the fine folks at Simple Directmedia Layer, from the SDL 3.4.18 era of the manual β€” go forth and callback responsibly πŸ¦‹

πŸ“¦ where this page comes from