Class NativeFileDialog
- java.lang.Object
-
- org.lwjgl.util.nfd.NativeFileDialog
-
public class NativeFileDialog extends java.lang.Object
Bindings to Native File Dialog, a tiny, neat C library that portably invokes native file open and save dialogs. Write dialog code once and have it pop up native dialogs on all supported platforms.Usage
File Filter Syntax
There is a form of file filtering in every file dialog, but no consistent means of supporting it. NFD provides support for filtering files by groups of extensions, providing its own descriptions (where applicable) for the extensions.
A wildcard filter is always added to every dialog.
Separators:
- ; Begin a new filter.
- , Add a separate type to the filter.
Examples:
- txt The default filter is for text files. There is a wildcard option in a dropdown.
- png,jpg;psd The default filter is for png and jpg files. A second filter is available for psd files. There is a wildcard option in a dropdown.
NULL
Wildcard only.
Known Limitations
- No support for Windows XP's legacy dialogs such as GetOpenFileName.
- No support for file filter names -- ex: "Image Files" (*.png, *.jpg). Nameless filters are supported, though.
- No support for selecting folders instead of files.
- On Linux, GTK+ cannot be uninitialized to save memory. Launching a file dialog costs memory.
-
-
Field Summary
Fields Modifier and Type Field Description static int
NFD_CANCEL
NFD_ERROR
NFD_OKAYResult values.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
NFD_Free(java.nio.ByteBuffer outPath)
Frees memory allocated by NativeFileDialog.static java.lang.String
NFD_GetError()
Returns the last error.static int
NFD_OpenDialog(java.lang.CharSequence filterList, java.lang.CharSequence defaultPath, org.lwjgl.PointerBuffer outPath)
Launches a single file open dialog.static int
NFD_OpenDialog(java.nio.ByteBuffer filterList, java.nio.ByteBuffer defaultPath, org.lwjgl.PointerBuffer outPath)
Launches a single file open dialog.static int
NFD_OpenDialogMultiple(java.lang.CharSequence filterList, java.lang.CharSequence defaultPath, NFDPathSet outPaths)
Launches a multiple file open dialog.static int
NFD_OpenDialogMultiple(java.nio.ByteBuffer filterList, java.nio.ByteBuffer defaultPath, NFDPathSet outPaths)
Launches a multiple file open dialog.static void
NFD_PathSet_Free(NFDPathSet pathSet)
Frees the contents of the specified path set.static long
NFD_PathSet_GetCount(NFDPathSet pathSet)
Returns the number of entries stored inpathSet
.static java.lang.String
NFD_PathSet_GetPath(NFDPathSet pathSet, long index)
Returns the UTF-8 path at offsetindex
.static int
NFD_PickFolder(java.lang.CharSequence defaultPath, org.lwjgl.PointerBuffer outPath)
Launches a select folder dialog.static int
NFD_PickFolder(java.nio.ByteBuffer defaultPath, org.lwjgl.PointerBuffer outPath)
Launches a select folder dialog.static int
NFD_SaveDialog(java.lang.CharSequence filterList, java.lang.CharSequence defaultPath, org.lwjgl.PointerBuffer outPath)
Launches a save dialog.static int
NFD_SaveDialog(java.nio.ByteBuffer filterList, java.nio.ByteBuffer defaultPath, org.lwjgl.PointerBuffer outPath)
Launches a save dialog.static void
nNFD_Free(long outPath)
Unsafe version of:Free
static long
nNFD_GetError()
Unsafe version of:GetError
static int
nNFD_OpenDialog(long filterList, long defaultPath, long outPath)
Unsafe version of:OpenDialog
static int
nNFD_OpenDialogMultiple(long filterList, long defaultPath, long outPaths)
Unsafe version of:OpenDialogMultiple
static void
nNFD_PathSet_Free(long pathSet)
Unsafe version of:PathSet_Free
static long
nNFD_PathSet_GetCount(long pathSet)
Unsafe version of:PathSet_GetCount
static long
nNFD_PathSet_GetPath(long pathSet, long index)
Unsafe version of:PathSet_GetPath
static int
nNFD_PickFolder(long defaultPath, long outPath)
Unsafe version of:PickFolder
static int
nNFD_SaveDialog(long filterList, long defaultPath, long outPath)
Unsafe version of:SaveDialog
-
-
-
Method Detail
-
nNFD_OpenDialog
public static int nNFD_OpenDialog(long filterList, long defaultPath, long outPath)
Unsafe version of:OpenDialog
-
NFD_OpenDialog
public static int NFD_OpenDialog(@Nullable java.nio.ByteBuffer filterList, @Nullable java.nio.ByteBuffer defaultPath, org.lwjgl.PointerBuffer outPath) public static int NFD_OpenDialog(@Nullable java.lang.CharSequence filterList, @Nullable java.lang.CharSequence defaultPath, org.lwjgl.PointerBuffer outPath)
Launches a single file open dialog.If
OKAY
is returned,outPath
will contain a pointer to a UTF-8 encoded string. The user must free the string withFree
when it is no longer needed.- Parameters:
filterList
- an optional filter listdefaultPath
- an optional default pathoutPath
- returns the selected file path
-
nNFD_OpenDialogMultiple
public static int nNFD_OpenDialogMultiple(long filterList, long defaultPath, long outPaths)
Unsafe version of:OpenDialogMultiple
-
NFD_OpenDialogMultiple
public static int NFD_OpenDialogMultiple(@Nullable java.nio.ByteBuffer filterList, @Nullable java.nio.ByteBuffer defaultPath, NFDPathSet outPaths) public static int NFD_OpenDialogMultiple(@Nullable java.lang.CharSequence filterList, @Nullable java.lang.CharSequence defaultPath, NFDPathSet outPaths)
Launches a multiple file open dialog.If
OKAY
is returned,outPaths
will be filled with information about the selected file or files. The user must free that information withPathSet_Free
when it is no longer needed.- Parameters:
filterList
- an optional filter listdefaultPath
- an optional default pathoutPaths
- a path set that will be filled with the selected files
-
nNFD_SaveDialog
public static int nNFD_SaveDialog(long filterList, long defaultPath, long outPath)
Unsafe version of:SaveDialog
-
NFD_SaveDialog
public static int NFD_SaveDialog(@Nullable java.nio.ByteBuffer filterList, @Nullable java.nio.ByteBuffer defaultPath, org.lwjgl.PointerBuffer outPath) public static int NFD_SaveDialog(@Nullable java.lang.CharSequence filterList, @Nullable java.lang.CharSequence defaultPath, org.lwjgl.PointerBuffer outPath)
Launches a save dialog.If
OKAY
is returned,outPath
will contain a pointer to a UTF-8 encoded string. The user must free the string withFree
when it is no longer needed.- Parameters:
filterList
- an optional filter listdefaultPath
- an optional default pathoutPath
- returns the selected file path
-
nNFD_PickFolder
public static int nNFD_PickFolder(long defaultPath, long outPath)
Unsafe version of:PickFolder
-
NFD_PickFolder
public static int NFD_PickFolder(@Nullable java.nio.ByteBuffer defaultPath, org.lwjgl.PointerBuffer outPath) public static int NFD_PickFolder(@Nullable java.lang.CharSequence defaultPath, org.lwjgl.PointerBuffer outPath)
Launches a select folder dialog.If
OKAY
is returned,outPath
will contain a pointer to a UTF-8 encoded string. The user must free the string withFree
when it is no longer needed.- Parameters:
defaultPath
- an optional default pathoutPath
- returns the selected file path
-
nNFD_GetError
public static long nNFD_GetError()
Unsafe version of:GetError
-
NFD_GetError
@Nullable public static java.lang.String NFD_GetError()
Returns the last error.
-
nNFD_PathSet_GetCount
public static long nNFD_PathSet_GetCount(long pathSet)
Unsafe version of:PathSet_GetCount
-
NFD_PathSet_GetCount
public static long NFD_PathSet_GetCount(NFDPathSet pathSet)
Returns the number of entries stored inpathSet
.- Parameters:
pathSet
- the path set to query
-
nNFD_PathSet_GetPath
public static long nNFD_PathSet_GetPath(long pathSet, long index)
Unsafe version of:PathSet_GetPath
-
NFD_PathSet_GetPath
@Nullable public static java.lang.String NFD_PathSet_GetPath(NFDPathSet pathSet, long index)
Returns the UTF-8 path at offsetindex
.- Parameters:
pathSet
- the path set to queryindex
- the path offset
-
nNFD_PathSet_Free
public static void nNFD_PathSet_Free(long pathSet)
Unsafe version of:PathSet_Free
-
NFD_PathSet_Free
public static void NFD_PathSet_Free(NFDPathSet pathSet)
Frees the contents of the specified path set.- Parameters:
pathSet
- the path set
-
nNFD_Free
public static void nNFD_Free(long outPath)
Unsafe version of:Free
-
NFD_Free
public static void NFD_Free(java.nio.ByteBuffer outPath)
Frees memory allocated by NativeFileDialog.- Parameters:
outPath
- the string to free
-
-