SDL_SHOWFILEDIALOGWITHPROPERTIES(3)

πŸ’– SDL_ShowFileDialogWithProperties πŸ’–

okay bestie, so this one is from the SDL3 FUNCTIONS manual, and it's literally the ✨fanciest✨ way to pop open a file dialog. It's giving "I have a whole properties system and I'm not afraid to use it." πŸ’…


🌸 NAME 🌸

SDL_ShowFileDialogWithProperties β€” create and launch a file dialog with the specified properties.


✨ SYNOPSIS ✨

#include <SDL3/SDL_dialog.h>

void SDL_ShowFileDialogWithProperties(SDL_FileDialogType type, SDL_DialogFileCallback callback, void *userdata, SDL_PropertiesID props);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea: instead of passing a million args, you pass a props ID and set all your little wishes on it. These are the supported properties, no cap:

  • SDL_PROP_FILE_DIALOG_FILTERS_POINTER β€” a pointer to a list of SDL_DialogFileFilter structs, and those are the filters used for file-based selections. Lowkey important: it gets ignored if the dialog is an "Open Folder" dialog. And if it's non-NULL, the array of filters has to stay valid at least until the callback is invoked. So don't let it die early, bestie 😭
  • SDL_PROP_FILE_DIALOG_NFILTERS_NUMBER β€” the number of filters in that array of filters, if it exists.
  • SDL_PROP_FILE_DIALOG_WINDOW_POINTER β€” the window that the dialog should be modal for.
  • SDL_PROP_FILE_DIALOG_LOCATION_STRING β€” the default folder or file to start the dialog at.
  • SDL_PROP_FILE_DIALOG_MANY_BOOLEAN β€” true to allow the user to select more than one entry. (main character behavior fr fr)
  • SDL_PROP_FILE_DIALOG_TITLE_STRING β€” the title for the dialog.
  • SDL_PROP_FILE_DIALOG_ACCEPT_STRING β€” the label that the accept button should have.
  • SDL_PROP_FILE_DIALOG_CANCEL_STRING β€” the label that the cancel button should have.
⚠️ note that each platform may or may not support any of the properties. so like... vibe check your platform first, okay? πŸ™ˆ

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • type β€” the type of file dialog.
  • callback β€” a function pointer that gets invoked when the user selects a file and accepts, or cancels the dialog, or an error occurs. it's the glow-up moment, basically πŸ’«
  • userdata β€” an optional pointer to pass extra data to the callback when it will be invoked. lil care package for your callback 🫢
  • props β€” the properties to use.

πŸ’œ THREAD SAFETY πŸ’œ

This function should be called only from the main thread. periodt. 🚫

The callback, though? It may be invoked from the same thread or from a different one, depending on the OS's constraints. So it's giving "wherever the OS decides," and you just have to deal πŸ’€


⭐ AVAILABILITY ⭐

This function is available since SDL 3.2.0. so if you're on anything older, it's simply not gonna show up for you 😭


🌈 SEE ALSO 🌈


okay that's the whole page, you ate it, you understood it, iconic behavior πŸ’…βœ¨

this has been your girl signing off on behalf of Simple Directmedia Layer, running SDL 3.4.18 β€” go make some dialogs pop off, bestie πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from