summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2005-03-25 18:58:18 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2005-03-25 18:58:18 +0000
commitf5ed012b28231526a56e302a923d24f82a7fad2d (patch)
treed02d88f5b5584d735d8e27be36dbda1949d2a191 /src
parent2ccbfdccc91c9fd139ae5a6dcb48226323381a17 (diff)
Updated Fl_File_Chooser to correctly deselect other items when
the user picks a file or directory in multiple selection mode (only files or directories, not both at once...) Use the fl_file_chooser_ok_label() function in FLUID. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4191 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_File_Chooser2.cxx30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/Fl_File_Chooser2.cxx b/src/Fl_File_Chooser2.cxx
index 0544a1481..c9264d7c4 100644
--- a/src/Fl_File_Chooser2.cxx
+++ b/src/Fl_File_Chooser2.cxx
@@ -415,8 +415,36 @@ Fl_File_Chooser::fileListCB()
}
else
{
- // Strip any trailing slash from the directory name...
+ // Check if the user clicks on a directory when picking files;
+ // if so, make sure only that item is selected...
filename = pathname + strlen(pathname) - 1;
+
+ if ((type_ & MULTI) && !(type_ & DIRECTORY)) {
+ if (*filename == '/') {
+ // Clicked on a directory, deselect everything else...
+ int i = fileList->value();
+ fileList->deselect();
+ fileList->select(i);
+ } else {
+ // Clicked on a file - see if there are other directories selected...
+ int i;
+ const char *temp;
+ for (i = 1; i <= fileList->size(); i ++) {
+ if (i != fileList->value() && fileList->selected(i)) {
+ temp = fileList->text(i);
+ temp += strlen(temp) - 1;
+ if (*temp == '/') break; // Yes, selected directory
+ }
+ }
+
+ if (i <= fileList->size()) {
+ i = fileList->value();
+ fileList->deselect();
+ fileList->select(i);
+ }
+ }
+ }
+ // Strip any trailing slash from the directory name...
if (*filename == '/') *filename = '\0';
// puts("Setting fileName from fileListCB...");