diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_File_Chooser.cxx | 5 | ||||
| -rw-r--r-- | src/Fl_File_Chooser.fl | 8 | ||||
| -rw-r--r-- | src/Fl_File_Chooser2.cxx | 24 | ||||
| -rw-r--r-- | src/fl_file_dir.cxx | 38 |
4 files changed, 46 insertions, 29 deletions
diff --git a/src/Fl_File_Chooser.cxx b/src/Fl_File_Chooser.cxx index ca734ae1e..932690caf 100644 --- a/src/Fl_File_Chooser.cxx +++ b/src/Fl_File_Chooser.cxx @@ -211,6 +211,7 @@ const char * Fl_File_Chooser::label() { void Fl_File_Chooser::show() { window->hotspot(fileList); window->show(); +fileName->take_focus(); } int Fl_File_Chooser::shown() { @@ -264,6 +265,6 @@ int Fl_File_Chooser::type() { int Fl_File_Chooser::visible() { return window->visible(); } -FL_EXPORT char *fl_dir_chooser(const char *message,const char *fname); -FL_EXPORT char *fl_file_chooser(const char *message,const char *pat,const char *fname); +FL_EXPORT char *fl_dir_chooser(const char *message,const char *fname,int relative=0); +FL_EXPORT char *fl_file_chooser(const char *message,const char *pat,const char *fname,int relative=0); FL_EXPORT void fl_file_chooser_callback(void (*cb)(const char*)); diff --git a/src/Fl_File_Chooser.fl b/src/Fl_File_Chooser.fl index f78da0404..56f9175c9 100644 --- a/src/Fl_File_Chooser.fl +++ b/src/Fl_File_Chooser.fl @@ -150,8 +150,8 @@ rescan();} {} Function {show()} {open return_type void } { code {window->hotspot(fileList); -window->show();} {selected - } +window->show(); +fileName->take_focus();} {} } Function {shown()} {return_type int } { @@ -217,10 +217,10 @@ else } } -decl {FL_EXPORT char *fl_dir_chooser(const char *message,const char *fname);} {public +decl {FL_EXPORT char *fl_dir_chooser(const char *message,const char *fname,int relative=0);} {public } -decl {FL_EXPORT char *fl_file_chooser(const char *message,const char *pat,const char *fname);} {public +decl {FL_EXPORT char *fl_file_chooser(const char *message,const char *pat,const char *fname,int relative=0);} {selected public } decl {FL_EXPORT void fl_file_chooser_callback(void (*cb)(const char*));} {public diff --git a/src/Fl_File_Chooser2.cxx b/src/Fl_File_Chooser2.cxx index 57696eb11..9a08dbb01 100644 --- a/src/Fl_File_Chooser2.cxx +++ b/src/Fl_File_Chooser2.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_File_Chooser2.cxx,v 1.1.2.10 2002/05/01 08:51:59 easysw Exp $" +// "$Id: Fl_File_Chooser2.cxx,v 1.1.2.11 2002/05/01 12:41:21 easysw Exp $" // // More Fl_File_Chooser routines. // @@ -575,7 +575,8 @@ Fl_File_Chooser::fileNameCB() fl_alert("Please choose an existing file!"); } } - else if (Fl::event_key() != FL_Delete) + else if (Fl::event_key() != FL_Delete && + Fl::event_key() != FL_BackSpace) { // Check to see if the user has entered a directory... if ((slash = strrchr(pathname, '/')) == NULL) @@ -673,17 +674,11 @@ Fl_File_Chooser::fileNameCB() fileName->replace(filename - pathname, filename - pathname + min_match, matchname); - // Highlight it; if the user just pressed the backspace - // key, position the cursor at the start of the selection. - // Otherwise, put the cursor at the end of the selection so + // Highlight it with the cursor at the end of the selection so // s/he can press the right arrow to accept the selection // (Tab and End also do this for both cases.) - if (Fl::event_key() == FL_BackSpace) - fileName->position(filename - pathname + min_match - 1, - filename - pathname + max_match); - else - fileName->position(filename - pathname + max_match, - filename - pathname + min_match); + fileName->position(filename - pathname + max_match, + filename - pathname + min_match); } else if (max_match == 0) { fileList->deselect(0); @@ -696,10 +691,15 @@ Fl_File_Chooser::fileNameCB() okButton->activate(); else okButton->deactivate(); + } else { + // FL_Delete or FL_BackSpace + fileList->deselect(0); + fileList->redraw(); + okButton->deactivate(); } } // -// End of "$Id: Fl_File_Chooser2.cxx,v 1.1.2.10 2002/05/01 08:51:59 easysw Exp $". +// End of "$Id: Fl_File_Chooser2.cxx,v 1.1.2.11 2002/05/01 12:41:21 easysw Exp $". // diff --git a/src/fl_file_dir.cxx b/src/fl_file_dir.cxx index c1d0f6d4f..089d1d3ce 100644 --- a/src/fl_file_dir.cxx +++ b/src/fl_file_dir.cxx @@ -1,5 +1,5 @@ // -// "$Id: fl_file_dir.cxx,v 1.1.2.9 2002/04/28 08:42:33 easysw Exp $" +// "$Id: fl_file_dir.cxx,v 1.1.2.10 2002/05/01 12:41:21 easysw Exp $" // // File chooser widget for the Fast Light Tool Kit (FLTK). // @@ -43,9 +43,16 @@ void fl_file_chooser_callback(void (*cb)(const char*)) { } -char* fl_file_chooser(const char* message, const char* pat, const char* fname) -{ - static char retname[1024]; +// +// 'fl_file_chooser()' - Show a file chooser dialog and get a filename. +// + +char * // O - Filename or NULL +fl_file_chooser(const char *message, // I - Message in titlebar + const char *pat, // I - Filename pattern + const char *fname, // I - Initial filename selection + int relative) { // I - 0 for absolute path + static char retname[1024]; // Returned filename if (!fc) { if (!fname || !*fname) fname = "."; @@ -88,17 +95,25 @@ char* fl_file_chooser(const char* message, const char* pat, const char* fname) while (fc->shown()) Fl::wait(); - if (fc->value()) { + if (fc->value() && relative) { fl_filename_relative(retname, sizeof(retname), fc->value()); return retname; - } else return 0; + } else if (fc->value()) return fc->value(); + else return 0; } -char* fl_dir_chooser(const char* message, const char* fname) +// +// 'fl_dir_chooser()' - Show a file chooser dialog and get a directory. +// + +char * // O - Directory or NULL +fl_dir_chooser(const char *message, // I - Message for titlebar + const char *fname, // I - Initial directory name + int relative) // I - 0 for absolute { - static char retname[1024]; + static char retname[1024]; // Returned directory name if (!fname || !*fname) fname = "."; @@ -118,14 +133,15 @@ char* fl_dir_chooser(const char* message, const char* fname) while (fc->shown()) Fl::wait(); - if (fc->value()) { + if (fc->value() && relative) { fl_filename_relative(retname, sizeof(retname), fc->value()); return retname; - } else return 0; + } else if (fc->value) return fc->value(); + else return 0; } // -// End of "$Id: fl_file_dir.cxx,v 1.1.2.9 2002/04/28 08:42:33 easysw Exp $". +// End of "$Id: fl_file_dir.cxx,v 1.1.2.10 2002/05/01 12:41:21 easysw Exp $". // |
