Is this possibly a bug in getOpenFile or maybe the Windows dialog?
Mac
#!perl
#Run the program and click the 'Browse' button. Drag the file
selection
#dialog so that the 'Create Output' button is located behind the file
#name you want. Double-click the file name and see if the 'Create
#Output' button is clicked.
use Tk;
use Tk::LabEntry;
use vars qw/ $main /;
my $main = Tk::MainWindow->new(-title => 'Test Tk Error',);
my $selFnFrame = $main->Frame;
my $selectedFn = '';
my $selFn_Entry = $selFnFrame->LabEntry
(-label => 'Selected File:', -width => 40,
-labelPack => [qw/-side left -anchor w/],
-validate => focusout,
-textvariable => \$selectedFn)->pack(qw/-side left -anchor w
-expand 1 -fill x/);
$selFn_Entry->focus();
my $selFn_Button = $selFnFrame->Button(-text => 'Browse');
$selFn_Button->pack(qw/-side right -pady 15 -padx 10/);
my $goFrame = $main->Frame;
my $go_Button = $goFrame->Button(-text => 'Create Output',
-padx => 60, -pady => 60);
$go_Button->pack(qw/ -pady 10 -padx 10/);
my $rpCommand = sub {&GetFileNm('Selected File', \$selectedFn)};
$selFn_Button->configure(-command => $rpCommand);
$go_Button->configure(-command => \&Go_Button_command);
$selFnFrame->pack(qw/-side top -fill x/);
$goFrame->pack(qw/-side top -fill x/);
MainLoop;
sub GetFileNm {
my($msg,$filenm) = @_;
my $lastfile = (-f $$filenm) ? $$filenm : '';
my ( @file, $file );
my ( @parms );
push @parms,-defaultextension => '.csv',
-title => "Select $msg";
push @parms, -initialfile => $lastfile if $lastfile;
$file = $main->getOpenFile( @parms);
$$filenm = $file;
}
sub Go_Button_command {
$main->messageBox(
'-icon' => error, -type => Ok,
-title => 'Error',
-message => 'The Create Output Button was
pressed!');
}
Sorry, should have done a search first - this appears to be a very old
problem. Wonder why no solution yet?
Mac
It may be an old problem, but I don't see that anyone has
submitted a bug report for it. It seems to be a Windows-only
problem.
http://rt.cpan.org/Public/Dist/Display.html?Status=Active&Name=Tk
I think that it might not be a Tk problem. I was able to reproduce it
using Win32::GUI->GetOpenFile, so it may be a bug in the native
Windows dialog.