diff options
| author | Greg Ercolano <erco@seriss.com> | 2013-08-15 23:01:15 +0000 |
|---|---|---|
| committer | Greg Ercolano <erco@seriss.com> | 2013-08-15 23:01:15 +0000 |
| commit | 33933f8c13c67618dae34eec4a3d5a7f693a592e (patch) | |
| tree | a8bb89c70a61315fa270e724e93d58c4cfee5420 /test/native-filechooser.cxx | |
| parent | 3e96dfe855bdc754edaa15d5f9bf7b46c2c55989 (diff) | |
Added "Pick Dir" button to allow checking of directory browsing.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9957 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test/native-filechooser.cxx')
| -rw-r--r-- | test/native-filechooser.cxx | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/test/native-filechooser.cxx b/test/native-filechooser.cxx index a652a1cfd..2f6266391 100644 --- a/test/native-filechooser.cxx +++ b/test/native-filechooser.cxx @@ -28,7 +28,7 @@ // GLOBALS Fl_Input *G_filename = NULL; -void Butt_CB(Fl_Widget*, void*) { +void PickFile_CB(Fl_Widget*, void*) { // Create native chooser Fl_Native_File_Chooser native; native.title("Pick a file"); @@ -51,6 +51,26 @@ void Butt_CB(Fl_Widget*, void*) { } } +void PickDir_CB(Fl_Widget*, void*) { + // Create native chooser + Fl_Native_File_Chooser native; + native.title("Pick a Directory"); + native.directory(G_filename->value()); + native.type(Fl_Native_File_Chooser::BROWSE_DIRECTORY); + // Show native chooser + switch ( native.show() ) { + case -1: fprintf(stderr, "ERROR: %s\n", native.errmsg()); break; // ERROR + case 1: fprintf(stderr, "*** CANCEL\n"); fl_beep(); break; // CANCEL + default: // PICKED DIR + if ( native.filename() ) { + G_filename->value(native.filename()); + } else { + G_filename->value("NULL"); + } + break; + } +} + int main(int argc, char **argv) { //// For a nicer looking browser under linux, call Fl_File_Icon::load_system_icons(); //// (If you do this, you'll need to link with fltk_images) @@ -79,7 +99,9 @@ int main(int argc, char **argv) { G_filename->tooltip("Default filename"); y += G_filename->h() + 5; Fl_Button *but = new Fl_Button(win->w()-80-10, win->h()-25-10, 80, 25, "Pick File"); - but->callback(Butt_CB); + but->callback(PickFile_CB); + Fl_Button *butdir = new Fl_Button(but->x()-80-10, win->h()-25-10, 80, 25, "Pick Dir"); + butdir->callback(PickDir_CB); Fl_Box *dummy = new Fl_Box(80, 0, 430, 100); dummy->hide(); win->resizable(dummy); |
