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 ofSDL_DialogFileFilterstructs, 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βtrueto 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 π
SDL_FileDialogType(3type)SDL_DialogFileCallback(3type)SDL_DialogFileFilter(3type)SDL_ShowOpenFileDialog(3)SDL_ShowSaveFileDialog(3)SDL_ShowOpenFolderDialog(3)
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
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms