This class lets an FLTK application easily and consistently access the operating system's native file chooser.
More...
This class lets an FLTK application easily and consistently access the operating system's native file chooser.
Some operating systems have very complex and specific file choosers that many users want access to specifically, instead of FLTK's default file chooser(s).
In cases where there is no native file browser, FLTK's own file browser is used instead.
To use this widget, use the following include in your code:
Fl_Native_File_Chooser widget.
The following example shows how to pick a single file:
[..]
fnfc.
title(
"Pick a file");
"C Files\t*.{cxx,h,c}");
case -1: printf(
"ERROR: %s\n", fnfc.
errmsg());
break;
case 1: printf("CANCEL\n"); break;
default: printf(
"PICKED: %s\n", fnfc.
filename());
break;
}
This class lets an FLTK application easily and consistently access the operating system's native file...
Definition: Fl_Native_File_Chooser.H:111
const char * filter() const
Returns the filter string last set.
Definition: Fl_Native_File_Chooser_FLTK.cxx:173
void title(const char *t)
Set the title of the file chooser's dialog window.
Definition: Fl_Native_File_Chooser_FLTK.cxx:161
void directory(const char *val)
Preset the directory the browser will show when opened.
Definition: Fl_Native_File_Chooser_FLTK.cxx:149
const char * errmsg() const
Returns a system dependent error message for the last method that failed.
Definition: Fl_Native_File_Chooser_FLTK.cxx:233
void type(int t)
Sets the current Fl_Native_File_Chooser::Type of browser.
Definition: Fl_Native_File_Chooser_FLTK.cxx:77
const char * filename() const
Return the filename the user chose.
Definition: Fl_Native_File_Chooser_FLTK.cxx:126
@ BROWSE_FILE
browse files (lets user choose one file)
Definition: Fl_Native_File_Chooser.H:114
int show()
Post the chooser's dialog.
Definition: Fl_Native_File_Chooser_FLTK.cxx:242
The Fl_Native_File_Chooser widget transmits UTF-8 encoded filenames to its user. It is recommended to open files that may have non-ASCII names with the fl_fopen() or fl_open() utility functions that handle these names in a cross-platform way (whereas the standard fopen()/open() functions fail on the MSWindows platform to open files with a non-ASCII name).
Platform Specific Caveats
The Fl_Native_File_Chooser on different platforms.
void Fl_Native_File_Chooser::filter |
( |
const char * |
f | ) |
|
Sets the filename filters used for browsing.
The default is NULL, which browses all files.
The filter string can be any of:
- A single wildcard (eg. "*.txt")
- Multiple wildcards (eg. "*.{cxx,h,H}")
- A descriptive name followed by a "\t" and a wildcard (eg. "Text Files\t*.txt")
- A list of separate wildcards with a "\n" between each (eg. "*.{cxx,H}\n*.txt")
- A list of descriptive names and wildcards (eg. "C++ Files\t*.{cxx,H}\nTxt Files\t*.txt")
The format of each filter is a wildcard, or an optional user description followed by '\t' and the wildcard.
On most platforms, each filter is available to the user via a pulldown menu in the file chooser. The 'All Files' option is always available to the user.