Commit d0cb5f02 authored by Stefan Tauner's avatar Stefan Tauner
Browse files

FIJIModalDialog: automatically add escape binding if possible

parent c2b72501
......@@ -25,11 +25,26 @@ 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);
Tk::FIJIUtils::set_icon($self);
my $esc_button;
if (@buttons == 1) {
$esc_button = @buttons[0];
} else {
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']);
$self->add('Label', -image => $image)->pack(-side => 'left') if (defined $image);
if (defined $markuptext) {
......
......@@ -1369,8 +1369,6 @@ sub _select_net_dialog {
my $d = $self->DialogBox(-title=>$title, -buttons=>[qw/OK Cancel/],-default_button=>'OK');
$d->bind('<Return>', => sub {});
my $cancel = $d->Subwidget('B_Cancel');
$d->bind('<Escape>' => [$cancel, 'Invoke']);
my $sel = $d->FIJINetSelection(-nets =>$self->{'nets'}, -netname_ref=>$netname_ref);
$sel->pack(-expand=>1,-fill=>'both',-padx=>5,-pady=>5);
......@@ -1429,8 +1427,6 @@ sub _select_driver_dialog($) {
# Build the DialogBox
my $d = $self->DialogBox(-title => "Driver for FIU $fiu_idx", -buttons => ["OK", "Cancel"]);
my $f = $d->add('Frame');
my $cancel = $d->Subwidget('B_Cancel');
$d->bind('<Escape>' => [$cancel, 'Invoke']);
Tk::FIJIUtils::set_icon($d);
$f->Label(-text => "Select the driver for net \"" . $netpath . "\"", -justify => "left")->grid(-row => 0, -column => 0, -columnspan => 2, -sticky => "w");
......
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