SDL Wiki
(This is the documentation for SDL3, which is the current stable version. SDL2 was the previous version!)

SDL_ShowOpenFolderDialog

Displays a dialog that lets the user select a folder on their filesystem.

Header File

Defined in <SDL3/SDL_dialog.h>

Syntax

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

Function Parameters

SDL_DialogFileCallback callback an SDL_DialogFileCallback to be invoked when the user selects a file and accepts, or cancels the dialog, or an error occurs. The first argument is a null-terminated list of C strings, representing the paths chosen by the user. The list will be empty if the user canceled the dialog, and it will be NULL if an error occurred. If an error occurred, it can be fetched with SDL_GetError(). The second argument is the userdata pointer passed to the function. The third argument is always -1 for SDL_ShowOpenFolderDialog.
void * userdata an optional pointer to pass extra data to the callback when it will be invoked.
SDL_Window * window the window that the dialog should be modal for, may be NULL. Not all platforms support this option.
const char * default_location the default folder or file to start the dialog at, may be NULL. Not all platforms support this option.
bool allow_many if non-zero, the user will be allowed to select multiple entries. Not all platforms support this option.

Remarks

This function should only be invoked from the main thread.

This is an asynchronous function; it will return immediately, and the result will be passed to the callback.

The callback will be invoked with a null-terminated list of files the user chose. The list will be empty if the user canceled the dialog, and it will be NULL if an error occurred.

Note that the callback may be called from a different thread than the one the function was invoked on.

Depending on the platform, the user may be allowed to input paths that don't yet exist.

On Linux, dialogs may require XDG Portals, which requires DBus, which requires an event-handling loop. Apps that do not use SDL to handle events should add a call to SDL_PumpEvents in their main loop.

Version

This function is available since SDL 3.1.3.

See Also


CategoryAPI, CategoryAPIFunction, CategoryDialog


[ edit | delete | history | feedback | raw ]

[ front page | index | search | recent changes | git repo | offline html ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.