SDL_ShowOpenFolderDialog(3)

πŸ’– SDL_ShowOpenFolderDialog πŸ’–

okay bestie, welcome to the SDL_ShowOpenFolderDialog(3) page, straight out of the SDL3 FUNCTIONS lineup 🫢


✨ NAME ✨

SDL_ShowOpenFolderDialog β€” pops up a lil dialog that lets the user pick a folder off their filesystem πŸŽ€


✨ SYNOPSIS ✨

#include <SDL3/SDL_dialog.h>

void SDL_ShowOpenFolderDialog(SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const char *default_location, bool allow_many);

✨ DESCRIPTION ✨

so this one is asynchronous, meaning it dips out immediately and hands the result over to your callback later. no waiting around, she's busy πŸ’…

The callback gets invoked with a null-terminated list of the files the user chose. If the user canceled the dialog, that list is empty. If something went wrong, the list is NULL 😭

heads up: the callback may get called from a different thread than the one you invoked the function on. stay woke 🧚

Depending on the platform, the user might be allowed to type in paths that don't even exist yet. yes fr fr.

On Linux, dialogs may require XDG Portals, which requires DBus, which requires an event-handling loop. So if your app does not use SDL to handle events, add a call to SDL_PumpEvents in your main loop. periodt πŸ‘‘


✨ FUNCTION PARAMETERS ✨

  • callback β€” a function pointer that gets invoked when the user selects a file and accepts, or cancels the dialog, or an error happens 🌸
  • userdata β€” an optional pointer you can pass extra data through to the callback when it gets invoked πŸ’œ
  • window β€” the window the dialog should be modal for, may be NULL. Not all platforms support this option πŸ™ˆ
  • default_location β€” the default folder or file to start the dialog at, may be NULL. Not all platforms support this option πŸ¦‹
  • allow_many β€” if non-zero, the user will be allowed to select multiple entries. Not all platforms support this option ✨

✨ THREAD SAFETY ✨

Call this function from the main thread only, bestie. The callback itself may be invoked from the same thread or from a different one, depending on whatever constraints the OS is serving that day 😌


✨ AVAILABILITY ✨

This function is available since SDL 3.2.0 πŸŽ€


✨ SEE ALSO ✨


and that's the whole page, you ate it πŸ’…βœ¨

This was brought to you by Simple Directmedia Layer, version SDL 3.4.18 β€” go pick a folder, main character πŸ‘‘πŸŒΈ

πŸ“¦ where this page comes from