Here's a fluid file that is probably a good way to do it. The goal here: * Create an 'Application' class that contains:
a) a menubar that has File->Open and File->Save b) Two Fl_File_Chooser widgets; open_dialog and save_dialog which are hidden by default * When File->Open is selected, the callback opens the "Open" file chooser by show()ing it * When File->Save is selected, the callback opens the "Save" file chooser by show()ing it You should be able to select the items to open the dialogs, and when you hit either OK or Cancel, the Fl_File_Chooser automatically handles hide()ing the dialogs. I didn't put in any code to handle the OK buttons in the choosers; that's up to you. See the docs on Fl_File_Chooser for how to handle those buttons, and how to manipulate the contents of the dialogs so that you can do things with what the user selected or typed in. You should be able to copy/paste the following into a 'foo.fl' file, load it into fluid, then hit File->Write Code to generate the foo.h and foo.cxx files which you should then be able to compile. Look at the properties for each item in the fluid hierarchy to see what settings I've made, or just look closely at the .fl file below; it's surprisingly human readable. (Most widget builder's files aren't!) * * * # data file for the Fltk User Interface Designer (fluid) version 1.0108 header_name {.h} code_name {.cxx} decl {\#include <FL/Fl_File_Chooser.H>} {public global } class MyApplication {open : {public Fl_Window} } { decl {Fl_File_Chooser *open_dialog;} {} decl {Fl_File_Chooser *save_dialog;} {} Function {MyApplication(int X,int Y):Fl_Window(X,Y)} {open } { Fl_Window {} { label {My Application} open xywh {1192 290 400 200} type Double resizable class Fl_Group visible } { Fl_Menu_Bar {} {open xywh {0 0 415 20} } { Submenu {} { label File open xywh {0 0 63 21} } { MenuItem {} { label Open callback {open_dialog->show();} xywh {0 0 31 21} } MenuItem {} { label Save callback {save_dialog->show();} xywh {0 0 31 21} } } } } code {// MyApplication: CONSTRUCTOR open_dialog = new Fl_File_Chooser(".", 0, Fl_File_Chooser::SINGLE, "Open File"); save_dialog = new Fl_File_Chooser(".", 0, Fl_File_Chooser::CREATE, "Save File");} {selected } } } Function {} {open } { code {MyApplication *app = new MyApplication(400,200); app->show(); return(Fl::run());} {} } * * * _______________________________________________ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk