#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = new MainWindow(); # 1. Entry $mw->Label(-text=>'Label 1: ')->pack; my $e1 = $mw->Entry()->pack; # 2. Entry $mw->Label(-text=>'Label 2: ')->pack; my $e2 = $mw->Entry()->pack; # Exit-Button $mw->Button(-text=>'End', -command=>sub {exit} )->pack; # -- Define Bindings -- # -- "Do play a Beep when ist pressed - except # -- for: focus is on $e1" $mw->bind("", sub { print "\a"; print "beep\n"; } ); $e1->bind("", sub { } ); my (@bt) = $e1->bindtags; print "before-> @bt\n"; #In order to change the beep in the entry, without #affecting the $mw beep, you must change the bindtags #for $e1. Remove the toplevel and 'all' specs, or at #least move them to the end of the bind order. $e1->bindtags([$e1, ref($e1)]); # or, depending on your requirements... #$e1->bindtags([$e1, ref($e1), $e1->toplevel, 'all']); (@bt) = $e1->bindtags; print "after-> @bt\n"; MainLoop;