Files can be filtered by file extension groups:
nfdfilteritem_t filterItem[2] = { { "Source code", "c,cpp,cc" }, { "Headers", "h,hpp" } };
A file filter is a pair of strings comprising the friendly name and the specification (multiple file extensions are comma-separated).
A list of file filters can be passed as an argument when invoking the library.
A wildcard filter is always added to every dialog.
Note
On MacOS, the file dialogs do not have friendly names and there is no way to switch between filters, so the filter specifications are combined (e.g. "c,cpp,cc,h,hpp"). The filter specification is also never explicitly shown to the user. This is usual MacOS behaviour and users expect it.
Note 2: You must ensure that the specification string is non-empty and that every file extension has at least one character. Otherwise, bad things might ensue (i.e. undefined behaviour).
Note 3: On Linux, the file extension is appended (if missing) when the user presses down the "Save" button. The appended file extension will remain visible to the user, even if an overwrite prompt is shown and the user then presses "Cancel".
Note 4: On Windows, the default folder parameter is only used if there is no recently used folder available. Otherwise, the default folder will be the
folder that was last used. Internally, the Windows implementation calls IFileDialog::SetDefaultFolder(IShellItem). This is usual Windows
behaviour and users expect it.
A file open dialog that supports multiple selection produces a PathSet, which is a thin abstraction over the platform-specific collection.
There are two ways to iterate over a PathSet:
This method does array-like access on the PathSet, and is the easiest to use. However, on certain platforms (Linux, and possibly Windows), it
takes O(N2) time in total to iterate the entire PathSet, because the underlying platform-specific implementation uses a linked list.
This method uses an enumerator object to iterate the paths in the PathSet. It is guaranteed to take O(N) time in total to iterate the entire
PathSet.
NFDe is known to work with SDL2 and GLFW, and should also work with other platform abstraction framworks. However, you should initialize NFDe after
initializing the framework, and probably should deinitialize NFDe before deinitializing the framework. This is because some frameworks expect to be
initialized on a "clean slate", and they may configure the system in a different way from NFDe. Init is generally very careful not to disrupt the
existing configuration unless necessary, and Quit restores the configuration back exactly to what it was before initialization.
GetOpenFileName.stdout or stderr about this.| Modifier and Type | Field and Description |
|---|---|
| public static final int | NFD_CANCEL
Result values. |
| public static final int | NFD_ERROR
Result values. |
| public static final int | NFD_OKAY
Result values. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public static native void | |
| public static void | |
| public static void | |
| public static String | |
| public static native int | NFD_Init()
Initialize NFD - call this for every thread that might use NFD, before calling any other NFD functions on that thread. |
| public static int | NFD_OpenDialog(PointerBuffer outPath, NFDFilterItem.
if defaultPath)NULL, the operating system will decideSingle file open dialog. |
| public static int | NFD_OpenDialog(PointerBuffer outPath, NFDFilterItem.
if defaultPath)NULL, the operating system will decideSingle file open dialog. |
| public static int | NFD_OpenDialogMultiple(PointerBuffer outPath, NFDFilterItem.
if defaultPath)NULL, the operating system will decideMultiple file open dialog. |
| public static int | NFD_OpenDialogMultiple(PointerBuffer outPath, NFDFilterItem.
if defaultPath)NULL, the operating system will decideMultiple file open dialog. |
| public static int | NFD_PathSet_EnumNext(NFDPathSetEnum enumerator, PointerBuffer outPath)
Gets the next item from the path set enumerator. |
| public static void | |
| public static void | |
| public static void | |
| public static void | |
| public static int | |
| public static int | |
| public static int | |
| public static int | NFD_PathSet_GetPath(long pathSet, int index, PointerBuffer outPath)
Gets the UTF-8 path at offset index. |
| public static int | NFD_PickFolder(PointerBuffer outPath, ByteBuffer
if defaultPath)NULL, the operating system will decideSelect folder dialog. |
| public static int | NFD_PickFolder(PointerBuffer outPath, CharSequence
if defaultPath)NULL, the operating system will decideSelect folder dialog. |
| public static native void | |
| public static int | NFD_SaveDialog(PointerBuffer outPath, NFDFilterItem.
if defaultPath, ByteBuffer defaultName)NULL, the operating system will decideSave dialog. |
| public static int | NFD_SaveDialog(PointerBuffer outPath, NFDFilterItem.
if defaultPath, CharSequence defaultName)NULL, the operating system will decideSave dialog. |
| public static native void | |
| public static native long | |
| public static native int | nNFD_OpenDialog(long outPath, long filterList, int
if zero, filterCount, long defaultPath)filterList is ignored (you can use NULL)Unsafe version of: |
| public static native int | nNFD_OpenDialogMultiple(long outPath, long filterList, int
if zero, filterCount, long defaultPath)filterList is ignored (you can use NULL)Unsafe version of: |
| public static native int | |
| public static native void | |
| public static native void | |
| public static native void | |
| public static native int | |
| public static native int | |
| public static native int | |
| public static native int | |
| public static native int | |
| public static native int | nNFD_SaveDialog(long outPath, long filterList, int
if zero, filterCount, long defaultPath, long defaultName)filterList is ignored (you can use NULL)Unsafe version of: |
| NFD_CANCEL | back to summary |
|---|---|
| public static final int NFD_CANCEL Result values. ( Enum values: | |
| NFD_ERROR | back to summary |
|---|---|
| public static final int NFD_ERROR Result values. ( Enum values: | |
| NFD_OKAY | back to summary |
|---|---|
| public static final int NFD_OKAY Result values. ( Enum values: | |
| NativeFileDialog | back to summary |
|---|---|
| protected NativeFileDialog() | |
| NFD_ClearError | back to summary |
|---|---|
| public static native void NFD_ClearError() Clear the error | |
| NFD_FreePath | back to summary |
|---|---|
| public static void NFD_FreePath(ByteBuffer filePath) Free a file path that was returned by the dialogs. | |
| NFD_FreePath | back to summary |
|---|---|
| public static void NFD_FreePath(long filePath) Free a file path that was returned by the dialogs. | |
| NFD_GetError | back to summary |
|---|---|
| public static String NFD_GetError() Get last error -- set when Returns the last error that was set, or
| |
| NFD_Init | back to summary |
|---|---|
| public static native int NFD_Init() Initialize NFD - call this for every thread that might use NFD, before calling any other NFD functions on that thread.
| |
| NFD_OpenDialog | back to summary |
|---|---|
| public static int NFD_OpenDialog(PointerBuffer outPath, NFDFilterItem. Single file open dialog. It is the caller's responsibility to free
| |
| NFD_OpenDialog | back to summary |
|---|---|
| public static int NFD_OpenDialog(PointerBuffer outPath, NFDFilterItem. Single file open dialog. It is the caller's responsibility to free
| |
| NFD_OpenDialogMultiple | back to summary |
|---|---|
| public static int NFD_OpenDialogMultiple(PointerBuffer outPath, NFDFilterItem. Multiple file open dialog. It is the caller's responsibility to free
| |
| NFD_OpenDialogMultiple | back to summary |
|---|---|
| public static int NFD_OpenDialogMultiple(PointerBuffer outPath, NFDFilterItem. Multiple file open dialog. It is the caller's responsibility to free
| |
| NFD_PathSet_EnumNext | back to summary |
|---|---|
| public static int NFD_PathSet_EnumNext(NFDPathSetEnum enumerator, PointerBuffer outPath) Gets the next item from the path set enumerator. If there are no more items, then It is the caller's responsibility to free
| |
| NFD_PathSet_Free | back to summary |
|---|---|
| public static void NFD_PathSet_Free(long pathSet) Free the | |
| NFD_PathSet_FreeEnum | back to summary |
|---|---|
| public static void NFD_PathSet_FreeEnum(NFDPathSetEnum enumerator) Frees an enumerator of the path set. | |
| NFD_PathSet_FreePath | back to summary |
|---|---|
| public static void NFD_PathSet_FreePath(ByteBuffer filePath) Free the path gotten by | |
| NFD_PathSet_FreePath | back to summary |
|---|---|
| public static void NFD_PathSet_FreePath(long filePath) Free the path gotten by | |
| NFD_PathSet_GetCount | back to summary |
|---|---|
| public static int NFD_PathSet_GetCount(long pathSet, IntBuffer count) Gets the number of entries stored in Note that some paths might be invalid (
| |
| NFD_PathSet_GetCount | back to summary |
|---|---|
| public static int NFD_PathSet_GetCount(long pathSet, int[] count) Array version of:
| |
| NFD_PathSet_GetEnum | back to summary |
|---|---|
| public static int NFD_PathSet_GetEnum(long pathSet, NFDPathSetEnum outEnumerator) Gets an enumerator of the path set. It is the caller's responsibility to free
| |
| NFD_PathSet_GetPath | back to summary |
|---|---|
| public static int NFD_PathSet_GetPath(long pathSet, int index, PointerBuffer outPath) Gets the UTF-8 path at offset index. It is the caller's responsibility to free
| |
| NFD_PickFolder | back to summary |
|---|---|
| public static int NFD_PickFolder(PointerBuffer outPath, ByteBuffer defaultPath) Select folder dialog. It is the caller's responsibility to free
| |
| NFD_PickFolder | back to summary |
|---|---|
| public static int NFD_PickFolder(PointerBuffer outPath, CharSequence defaultPath) Select folder dialog. It is the caller's responsibility to free
| |
| NFD_Quit | back to summary |
|---|---|
| public static native void NFD_Quit() | |
| NFD_SaveDialog | back to summary |
|---|---|
| public static int NFD_SaveDialog(PointerBuffer outPath, NFDFilterItem. Save dialog. It is the caller's responsibility to free
| |
| NFD_SaveDialog | back to summary |
|---|---|
| public static int NFD_SaveDialog(PointerBuffer outPath, NFDFilterItem. Save dialog. It is the caller's responsibility to free
| |
| nNFD_FreePath | back to summary |
|---|---|
| public static native void nNFD_FreePath(long filePath) Unsafe version of: | |
| nNFD_GetError | back to summary |
|---|---|
| public static native long nNFD_GetError() Unsafe version of: | |
| nNFD_OpenDialog | back to summary |
|---|---|
| public static native int nNFD_OpenDialog(long outPath, long filterList, int filterCount, long defaultPath) Unsafe version of:
| |
| nNFD_OpenDialogMultiple | back to summary |
|---|---|
| public static native int nNFD_OpenDialogMultiple(long outPath, long filterList, int filterCount, long defaultPath) Unsafe version of:
| |
| nNFD_PathSet_EnumNext | back to summary |
|---|---|
| public static native int nNFD_PathSet_EnumNext(long enumerator, long outPath) Unsafe version of: | |
| nNFD_PathSet_Free | back to summary |
|---|---|
| public static native void nNFD_PathSet_Free(long pathSet) Unsafe version of: | |
| nNFD_PathSet_FreeEnum | back to summary |
|---|---|
| public static native void nNFD_PathSet_FreeEnum(long enumerator) Unsafe version of: | |
| nNFD_PathSet_FreePath | back to summary |
|---|---|
| public static native void nNFD_PathSet_FreePath(long filePath) Unsafe version of: | |
| nNFD_PathSet_GetCount | back to summary |
|---|---|
| public static native int nNFD_PathSet_GetCount(long pathSet, long count) Unsafe version of: | |
| nNFD_PathSet_GetCount | back to summary |
|---|---|
| public static native int nNFD_PathSet_GetCount(long pathSet, int[] count) Array version of: | |
| nNFD_PathSet_GetEnum | back to summary |
|---|---|
| public static native int nNFD_PathSet_GetEnum(long pathSet, long outEnumerator) Unsafe version of: | |
| nNFD_PathSet_GetPath | back to summary |
|---|---|
| public static native int nNFD_PathSet_GetPath(long pathSet, int index, long outPath) Unsafe version of: | |
| nNFD_PickFolder | back to summary |
|---|---|
| public static native int nNFD_PickFolder(long outPath, long defaultPath) Unsafe version of: | |
| nNFD_SaveDialog | back to summary |
|---|---|
| public static native int nNFD_SaveDialog(long outPath, long filterList, int filterCount, long defaultPath, long defaultName) Unsafe version of:
| |