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
This commit is contained in:
parent
3e96dfe855
commit
33933f8c13
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user