Hello,
Look this little sample (main is borrowed from Greg Ercolano sample):
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_File_Browser.H>
void BrowserCallback(Fl_Widget *w, void *data)
{
Fl_File_Browser *fileb = (Fl_File_Browser *) w;
int selected_file = fileb->value();
const char *path = fileb->text(selected_file);
fprintf(stderr,"well, i'm here: %s\n",path);
if (fl_filename_isdir (path) ) {
fprintf(stderr,"will go to: %s\n",path);
fileb->load(path);
}
}
int main(int argc, char **argv)
{
Fl_Double_Window win(300, 400, "File Browser");
Fl_File_Browser fbrow(10,10,300-20,400-20);
fbrow.load(".");
fbrow.type(FL_HOLD_BROWSER);
fbrow.callback(BrowserCallback);
win.end();
win.resizable(fbrow);
win.show(argc,argv);
return(Fl::run());
}
I don't think it's a bug, i even think it's a feature, but the problem
is:
Fl_File_Browser::load() won't change start path of application.
So, if you start here:
/tmp
and then you click on /tmp/foo , «load» will show you «/tmp/foo».
But when you click on «..», you'll end up in root directory /
(as in fact, fltk apply the «..» on «/tmp», which is start directory).
I know that C doesn't know what a «directory» is, and i believe that's
why «load» won't walk into directories.
I've thought of possible workaround, but it would force me into managing
strings, detecting directory and stepping up when encoutering «..»… well,
headache ahead!
Thank you for explaining me what is right, and what is wrong :)
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk