Commit 7099eb72 authored by Stefan Tauner's avatar Stefan Tauner
Browse files

Fix use of undefined variable in FIJIModalDialog by fetching buttons from DialogBoxUL

parent 14c5ab11
......@@ -93,6 +93,7 @@ sub Populate {
if (defined($accel)) {
$cw->bind("<Alt-$accel>" => [ $b, 'Invoke']);
}
push(@{$cw->{'buttons'}}, $bl);
}
if (defined $default_button && !$cw->{'default_button'}) {
warn "Default button `$default_button' does not exist.\n";
......@@ -109,6 +110,10 @@ sub Populate {
$cw->Delegates('Construct',$top);
}
sub buttons {
return \@{shift->{'buttons'}};
}
sub add {
my ($cw, $wnam, @args) = @_;
my $w = $cw->Subwidget('top')->$wnam(@args);
......
......@@ -25,27 +25,28 @@ sub Populate {
my $text = delete $args->{'-text'};
my $markuptext = delete $args->{'-markuptext'};
my $wraplength = delete $args->{'-wraplength'};
my @buttons = @{$args->{'-buttons'}};
$self->SUPER::Populate($args);
my $buttons = $self->buttons();
Tk::FIJIUtils::set_icon($self);
my $esc_button;
if (@buttons == 1) {
$esc_button = @buttons[0];
$esc_button =~ tr/~//d; # filter ~
if (@$buttons == 1) {
$esc_button = @$buttons[0];
} else {
foreach my $b (@buttons) {
$b =~ tr/~//d; # filter ~
foreach my $b (@$buttons) {
if ($b eq "Cancel") {
$esc_button = $b;
last;
}
}
}
$logger->debug("Binding escape to $esc_button");
$self->bind('<Escape>' => [$self->Subwidget("B_$esc_button"), 'Invoke']);
if (defined($esc_button)) {
$logger->debug("Binding escape to $esc_button");
$self->bind('<Escape>' => [$self->Subwidget("B_$esc_button"), 'Invoke']);
}
$self->add('Label', -image => $image)->pack(-side => 'left') if (defined $image);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment