Merge commit '004534c8e7e16c6414b6f7203be81829b0650411' as 'deps/nfde'
This commit is contained in:
36
deps/nfde/test/test_opendialog.c
vendored
Normal file
36
deps/nfde/test/test_opendialog.c
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
#include <nfd.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* this test should compile on all supported platforms */
|
||||
|
||||
int main(void) {
|
||||
// initialize NFD
|
||||
// either call NFD_Init at the start of your program and NFD_Quit at the end of your program,
|
||||
// or before/after every time you want to show a file dialog.
|
||||
NFD_Init();
|
||||
|
||||
nfdchar_t* outPath;
|
||||
|
||||
// prepare filters for the dialog
|
||||
nfdfilteritem_t filterItem[2] = {{"Source code", "c,cpp,cc"}, {"Headers", "h,hpp"}};
|
||||
|
||||
// show the dialog
|
||||
nfdresult_t result = NFD_OpenDialog(&outPath, filterItem, 2, NULL);
|
||||
if (result == NFD_OKAY) {
|
||||
puts("Success!");
|
||||
puts(outPath);
|
||||
// remember to free the memory (since NFD_OKAY is returned)
|
||||
NFD_FreePath(outPath);
|
||||
} else if (result == NFD_CANCEL) {
|
||||
puts("User pressed cancel.");
|
||||
} else {
|
||||
printf("Error: %s\n", NFD_GetError());
|
||||
}
|
||||
|
||||
// Quit NFD
|
||||
NFD_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user