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 and Description static int
NFD_CANCEL
User pressed cancel.static int
NFD_ERROR
Programmatic error.static int
NFD_OKAY
User pressed okay, or successful return.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and 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.nio.ByteBuffer filterList, java.nio.ByteBuffer defaultPath, PointerBuffer outPath)
Launches a single file open dialog.static int
NFD_OpenDialog(java.lang.CharSequence filterList, java.lang.CharSequence defaultPath, PointerBuffer outPath)
Launches a single file open dialog.static int
NFD_OpenDialogMultiple(java.nio.ByteBuffer filterList, java.nio.ByteBuffer defaultPath, NFDPathSet outPaths)
Launches a multiple file open dialog.static int
NFD_OpenDialogMultiple(java.lang.CharSequence filterList, java.lang.CharSequence 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_SaveDialog(java.nio.ByteBuffer filterList, java.nio.ByteBuffer defaultPath, PointerBuffer outPath)
Launches a save dialog.static int
NFD_SaveDialog(java.lang.CharSequence filterList, java.lang.CharSequence defaultPath, PointerBuffer outPath)
Launches a save dialog.
-
-
-
Field Detail
-
NFD_ERROR
public static final int NFD_ERROR
Programmatic error.- See Also:
- Constant Field Values
-
NFD_OKAY
public static final int NFD_OKAY
User pressed okay, or successful return.- See Also:
- Constant Field Values
-
NFD_CANCEL
public static final int NFD_CANCEL
User pressed cancel.- See Also:
- Constant Field Values
-
-
Method Detail
-
NFD_OpenDialog
public static int NFD_OpenDialog(java.nio.ByteBuffer filterList, java.nio.ByteBuffer defaultPath, 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
-
NFD_OpenDialog
public static int NFD_OpenDialog(java.lang.CharSequence filterList, java.lang.CharSequence defaultPath, 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
-
NFD_OpenDialogMultiple
public static int NFD_OpenDialogMultiple(java.nio.ByteBuffer filterList, java.nio.ByteBuffer 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
-
NFD_OpenDialogMultiple
public static int NFD_OpenDialogMultiple(java.lang.CharSequence filterList, 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
-
NFD_SaveDialog
public static int NFD_SaveDialog(java.nio.ByteBuffer filterList, java.nio.ByteBuffer defaultPath, 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
-
NFD_SaveDialog
public static int NFD_SaveDialog(java.lang.CharSequence filterList, java.lang.CharSequence defaultPath, 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
-
NFD_GetError
public static java.lang.String NFD_GetError()
Returns the last error.
-
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
-
NFD_PathSet_GetPath
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
-
NFD_PathSet_Free
public static void NFD_PathSet_Free(NFDPathSet pathSet)
Frees the contents of the specified path set.- Parameters:
pathSet
- the path set
-
NFD_Free
public static void NFD_Free(java.nio.ByteBuffer outPath)
Frees memory allocated by NativeFileDialog.- Parameters:
outPath
- the string to free
-
-