in reply to Perl-Tk, how to call the event object (entry)

Hi,

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); } }

Cheers, Christoph

Replies are listed 'Best First'.
Re^2: Perl-Tk, how to call the event object (entry)
by Anonymous Monk on Aug 10, 2009 at 05:25 UTC
    A lot of thanks, Christoph!

    Good luck!