Commit 39a045e5 authored by Christian Fibich's avatar Christian Fibich Committed by Stefan Tauner
Browse files

Re-bind <<Paste>> to allow CTRL+V to overwrite selected text

as expected

Moved rebinding to function in Tk::FIJIUtils, added calls to
this function for every entry.

Addresses issue vecs/fiji#63 discovered in usability test
parent 39d3e11e
......@@ -92,6 +92,7 @@ sub Populate {
my $balloon_widget = $self->Balloon();
my $search_entry = $self->Entry()->grid(-row => 0, -column => 0, -padx => 5, -pady => 5, -sticky => 'ew');
Tk::FIJIUtils::entry_rebind($search_entry);
my $search_button = $self->Button(-text => 'Search', -command => [\&callback, $self, $search_entry,])->grid(-row => 0, -column => 1, -padx => 5, -pady => 5, -sticky => 'e');
$search_entry->bind('<Return>', sub { $search_button->invoke; $_[0]->break; });
......
......@@ -767,14 +767,7 @@ sub _populate_widget {
);
}
$entry->bind(
'<Control-a>',
sub {
my $w = shift;
$w->selectionRange(0, 'end');
$w->icursor('end');
},
);
Tk::FIJIUtils::entry_rebind($entry);
# Widget description is needed for widget-based error messages such as
# "Forbids"
......@@ -1147,14 +1140,8 @@ sub _add_fiu ($$) {
);
$mask_entry->{'displaygroup'} = DISPLAYGROUPS_FIU_KEY;
$mask_entry->{'key'} = "FIU${i}_LFSR_MASK";
$mask_entry->bind(
'<Control-a>',
sub {
my $w = shift;
$w->selectionRange(0, 'end');
$w->icursor('end');
},
);
Tk::FIJIUtils::entry_rebind($mask_entry);
$self->{'balloon'}->attach(
$mask_entry,
-balloonposition => 'mouse',
......@@ -1298,6 +1285,8 @@ sub _rename_fiu_dialog {
my $e = $rename_dialog->Entry(-text=>@{$self->{settings}->{fius}}[$i]->{'FIU_NAME'});
$e->pack(-side=>'bottom');
$e->selectionRange(0, 'end');
Tk::FIJIUtils::entry_rebind($e);
$rename_dialog->configure('-focus' => $e);
my $rv = $rename_dialog->Show();
......
......@@ -158,6 +158,10 @@ sub _populate_widget ($) {
'-validatecommand' => [\&_check_timer_value, $self, $t2, 'TIMER_VALUE_2', $balloon, $warn_t2]
);
Tk::FIJIUtils::entry_rebind($t1);
Tk::FIJIUtils::entry_rebind($t2);
for my $w ($t1_label, $t1_unit, $t1) {
$balloon->attach($w, -balloonposition=>'mouse', -msg => "Duration until the first fault is activated.");
}
......
......@@ -818,14 +818,7 @@ sub _populate_widget {
);
}
$entry->bind(
'<Control-a>',
sub {
my $w = shift;
$w->selectionRange(0, 'end');
$w->icursor('end');
},
);
Tk::FIJIUtils::entry_rebind($entry);
# Widget description is needed for widget-based error messages such as
# "Forbids"
......
......@@ -355,4 +355,38 @@ sub highlight_widget ($$$) {
}
}
use Data::Dumper;
# Sets up the desired bindings for Entry widgets
# that differ from default behavior
sub entry_rebind($) {
my $entry = shift;
# select all
$entry->bind(
'<Control-a>',
sub {
my $w = shift;
$w->selectionRange(0, 'end');
$w->icursor('end');
$w->break;
},
);
# overwrite selection when pasting
$entry->bind(
'<<Paste>>',
sub {
my ($w, $d) = @_;
$w->deleteSelected;
$w->insert("insert", $w->clipboardGet);
$w->SeeInsert if $w->can('SeeInsert');
$w->break;
},
);
my @tags = $entry->bindtags();
$entry->bindtags([@tags[1, 0, 2, 3]]);
}
1;
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