SDL_InsertTrayEntryAt(3)

πŸ’– SDL_InsertTrayEntryAt(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we're talking about SDL_InsertTrayEntryAt β€” yes, the tray one, the little menu that lives in your system tray, and yes it's about to get cute AND correct, no cap. πŸŽ€


✨ NAME ✨

SDL_InsertTrayEntryAt β€” insert a tray entry at a given position. that's it, that's the whole job. lowkey iconic. πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_tray.h>

SDL_TrayEntry * SDL_InsertTrayEntryAt(SDL_TrayMenu *menu, int pos, const char *label, SDL_TrayEntryFlags flags);

she takes a menu, a position, a label and some flags, and she gives you back an entry. main character behavior fr fr. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: if label is NULL, the entry you get is a separator β€” a lil divider line, not a clickable thing. and heads up bestie, many functions won't work for an entry that is a separator. it's giving "decorative only", iykyk. πŸ™ˆ

and the best part? an entry does not need to be destroyed. nope. not your problem. it gets destroyed with the tray, automatically, like the tray is its parent and it's just tagging along. 🫢


🌈 FUNCTION PARAMETERS 🌈

  • menu β€” the menu you're appending the entry to. the place. the venue. the group chat. πŸ’¬
  • pos β€” the desired position for the new entry. everything at or following this spot gets moved (yes, shoved over, respectfully πŸ’€). and if pos is -1, the entry just gets appended to the end. easy.
  • label β€” the text shown on the entry, in UTF-8 encoding, or NULL if you want a separator instead. pick your fighter. πŸŽ€
  • flags β€” a combination of flags, some of which are mandatory. so like, don't skip them, bestie, they're not optional-optional. ⚠️

⭐ RETURN VALUE ⭐

returns the shiny newly created entry ✨ β€” or NULL if pos is out of bounds. so if you get NULL back, that's not a mystery, that's just bad coordinates. 🫠


🧚 THREAD SAFETY 🧚

this function should be called on the thread that created the tray. do not cheat on that thread. do not show up from a random other thread. she will know. πŸ’€


πŸ‘‘ AVAILABILITY πŸ‘‘

this function is available since SDL 3.2.0. so if you're on something older... no she's not there yet, sorry babe. 😭


πŸ’œ SEE ALSO πŸ’œ

go read those next, bestie, the lore goes deep. 🌸


quick reminder: separators are real entries but limited β€” many functions won't work on them. don't build your whole menu out of dividers and then act surprised. πŸ™ˆ

okay and that's a wrap!! this page came to you courtesy of Simple Directmedia Layer, rocking version SDL 3.4.18 β€” slay, periodt. πŸ’…βœ¨πŸŽ€ go insert some tray entries, you've got this. πŸ¦‹πŸ’–

πŸ“¦ where this page comes from