Hiba wrote:
> Good evening everybody.Please, i need your help.
> I created a simple browser interface, with the "browser" itself, the "file
> name" and a "save" button.
I'm assuming you're using FLTK 1.x.
Hmm, sounds like you're building your own file browser instead of using
the built in Fl_File_Chooser:
http://fltk.org/documentation.php/doc-1.1/Fl_File_Chooser.html#Fl_File_Chooser
..where paths get added based on the contents of the directory
the browser is pointing at. If you really want to browse files,
you should probably use that.
> I wanted to know:
> - how to add the paths in the browser
If you're using Fl_Browser to create your own browser, then you
would add strings to it with the add() method:
http://fltk.org/documentation.php/doc-1.1/Fl_Browser.html#Fl_Browser.add
> - what to do to save this file in that location
Assuming the user has clicked on one of the items in the list
you've built, and the item shows the pathname, then the callback
you set for the browser can access the item the user selected by
invoking:
your_browser->text(your_browser->value());
..where "your_browser" is your browser widget.
So putting that all together, your code might look something like:
--- snip
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Browser.H>
#include <stdio.h>
void BrowserCallback(Fl_Widget *w, void*)
{
Fl_Browser *your_browser = (Fl_Browser*)w;
printf("You picked %s\n", your_browser->text(your_browser->value()));
}
main()
{
Fl_Window *win = new Fl_Window(200, 200);
Fl_Browser *your_browser = new Fl_Browser(10,10,200-20,200-20);
your_browser->add("/some/pathname/foo.xxx");
your_browser->add("/some/pathname/bar.xxx");
your_browser->type(FL_SELECT_BROWSER);
your_browser->callback(BrowserCallback);
win->resizable(win);
win->show();
return(Fl::run());
}
--- snip
If you're using fluid to create your interface, you would still use
the add() method to add the items to the browser. You can do this
by selecting the browser, going into the 'C++' tab,
and setting 'Name:' to eg. 'my_browser',
and setting 'Extra Code:' to:
my_browser->add("/some/pathname/foo.xxx");
my_browser->add("/some/pathname/bar.xxx");
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk