# SDL_SetTrayMenuOpenCallback Sets a callback to be invoked when the menu is opened or closed. ## Header File Defined in [](https://github.com/libsdl-org/SDL/blob/main/include/SDL3/SDL_tray.h) ## Syntax ```c bool SDL_SetTrayMenuOpenCallback(SDL_TrayMenu *menu, SDL_TrayMenuOpenCallback callback, void *userdata); ``` ## Function Parameters | | | | | ---------------------------------------------------- | ------------ | ------------------------------------------------------------------------------- | | [SDL_TrayMenu](SDL_TrayMenu) * | **menu** | the menu to be updated. | | [SDL_TrayMenuOpenCallback](SDL_TrayMenuOpenCallback) | **callback** | a callback to be invoked when the menu is opened or closed. | | void * | **userdata** | an optional pointer to pass extra data to the callback when it will be invoked. | ## Return Value (bool) Returns true on success or false on failure; call [SDL_GetError](SDL_GetError)() for more information. ## Remarks The callback is invoked before the menu is displayed, so it can be used to update the menu contents, and again after the menu has closed. This works for both tray menus and submenus. This is not supported on Linux, where the desktop environment doesn't reliably report when a menu is opened and closed. ## Thread Safety This function should be called on the thread that created the tray. ## Version This function is available since SDL 3.6.0. ## See Also - [SDL_GetTraySubmenu](SDL_GetTraySubmenu) - [SDL_TrayMenuOpenCallback](SDL_TrayMenuOpenCallback) ---- [CategoryAPI](CategoryAPI), [CategoryAPIFunction](CategoryAPIFunction), [CategoryTray](CategoryTray)