the first arg passed to the callback is always the widget the binding was triggered on.
# It handles right-clicks on all entries of the main window $mwindow->bind("Tk::Entry", "<Button-3>", \&process_context_click ); # It makes the menu row 'Copy' and calls the sub callback my $popup = $mwindow->Menu( -tearoff => 0, -menuitems => [ ['command' => "~Copy", -command => \&callback] ] ); # It must copy the content of the event's entry to the clipboard, but. +.. {# private scope my $entry; sub process_context_click{ $entry = shift; $popup->Popup( -popover => "cursor", -popanchor => 'nw' ) } sub callback { my $f = $entry; my $g = $f->get(); $mw->clipboardAppend($g); } }
In reply to Re: Perl-Tk, how to call the event object (entry)
by lamprecht
in thread Perl-Tk, how to call the event object (entry)
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |