diff options
-rw-r--r-- | library/tkfbox.tcl | 5 | ||||
-rw-r--r-- | library/xmfbox.tcl | 9 | ||||
-rw-r--r-- | tests/filebox.test | 2 |
3 files changed, 10 insertions, 6 deletions
diff --git a/library/tkfbox.tcl b/library/tkfbox.tcl index a52465a..f73fdc5 100644 --- a/library/tkfbox.tcl +++ b/library/tkfbox.tcl @@ -310,6 +310,7 @@ proc ::tk::dialog::file::Config {dataName type argList} { # 5. Parse the -filetypes option # + set data(origfiletypes) $data(-filetypes) set data(-filetypes) [::tk::FDGetFileTypes $data(-filetypes)] if {![winfo exists $data(-parent)]} { @@ -1119,7 +1120,9 @@ proc ::tk::dialog::file::Done {w {selectFilePath ""}} { && [info exists data(filterType)] && $data(filterType) ne "" } then { upvar #0 $data(-typevariable) typeVariable - set typeVariable [lindex $data(filterType) 0] + set typeVariable [lindex $data(origfiletypes) \ + [lsearch -exact $data(-filetypes) $data(filterType)] 0] + } } bind $data(okBtn) <Destroy> {} diff --git a/library/xmfbox.tcl b/library/xmfbox.tcl index aa66f7f..14d2be5 100644 --- a/library/xmfbox.tcl +++ b/library/xmfbox.tcl @@ -156,7 +156,7 @@ proc ::tk::MotifFDialog_FileTypes {w} { # The filetypes radiobuttons # set data(fileType) $data(-defaulttype) # Default type to first entry - set initialTypeName [lindex $data(-filetypes) 0 0] + set initialTypeName [lindex $data(origfiletypes) 0 0] if {$data(-typevariable) ne ""} { upvar #0 $data(-typevariable) typeVariable if {[info exists typeVariable]} { @@ -165,7 +165,7 @@ proc ::tk::MotifFDialog_FileTypes {w} { } set ix 0 set data(fileType) 0 - foreach fltr $data(-filetypes) { + foreach fltr $data(origfiletypes) { set fname [lindex $fltr 0] if {[string first $initialTypeName $fname] == 0} { set data(fileType) $ix @@ -185,7 +185,7 @@ proc ::tk::MotifFDialog_FileTypes {w} { set cnt 0 if {$data(-filetypes) ne {}} { foreach type $data(-filetypes) { - set title [lindex [lindex $type 0] 0] + set title [lindex $type 0] set filter [lindex $type 1] radiobutton $f.b$cnt \ -text $title \ @@ -299,6 +299,7 @@ proc ::tk::MotifFDialog_Config {dataName type argList} { # file dialog, but we check for validity of the value to make sure # the application code also runs fine with the TK file dialog. # + set data(origfiletypes) $data(-filetypes) set data(-filetypes) [::tk::FDGetFileTypes $data(-filetypes)] if {![info exists data(filter)]} { @@ -870,7 +871,7 @@ proc ::tk::MotifFDialog_ActivateSEnt {w} { if {[info exists data(-typevariable)] && $data(-typevariable) ne "" && [info exists data(-filetypes)] && $data(-filetypes) ne ""} { upvar #0 $data(-typevariable) typeVariable - set typeVariable [lindex $data(-filetypes) $data(fileType) 0] + set typeVariable [lindex $data(origfiletypes) $data(fileType) 0] } if {$data(-multiple) != 0} { diff --git a/tests/filebox.test b/tests/filebox.test index 37c06ef..85cb8a5 100644 --- a/tests/filebox.test +++ b/tests/filebox.test @@ -281,7 +281,7 @@ foreach mode $modes { -initialfile $fileName -initialdir $fileDir \ -typevariable tv] if {[info exists tv]} { - regexp {^(.*) \(.*\)$} $tv dummy typeName + set typeName $tv } else { set typeName "-unset-" } |