in reply to Button Binding

Where is your code?

If a button has focus, enter already clicks the button, so which widget has the focus, that you want to respond to enter

Replies are listed 'Best First'.
Re^2: Button Binding (tk code)
by Anonymous Monk on Mar 18, 2015 at 23:27 UTC
    #!/usr/bin/perl -- use strict; use warnings; use Tk; my $mw = tkinit; $mw->Label( -text => "yo" )->pack; my $en = $mw->Entry( -text => "yo" )->pack; my $bb = $mw->Button( -command => \&warner )->pack; BuhBind( $mw, '<Enter>' ); ## mouse enter BuhBind( $en, '<Enter>' ); ## mouse enter BuhBind( $mw, '<KeyPress-Return>' ); BuhBind( $en, '<KeyPress-Return>' ); ## $mw->WidgetDump; ## debuggery $mw->MainLoop; sub BuhBind { my( $wig , $tag ) = @_; my $str = "$wig -> bind( $tag "; $wig->bind( $tag => sub { warn " $str ## @_ ## $Tk::widget \n"; return Tk->break ; ## do not propagate, if $en is responding +to return $mw doesn't have to } ); } sub warner { warn "warner ## @_ ## $Tk::widget \n"; }