#!/usr/bin/perl use strict; use warnings; use Tcl::pTk; use Tk::Text; my $mw = MainWindow->new(); my $text = $mw->Text()->pack(); PupupTextWidget($mw, $text);#If I comment out this, no popup (the original one) shows MainLoop; sub PupupTextWidget{ my ($mw, $obj) = @_; my $menu = $mw->Menu(-tearoff=>0, -menuitems=>[ [command=>'My command', -command=>[sub {print "something"}, $obj,]], ]); $obj->menu($menu); $obj->bind('<2>', ['PostPopupMenu', Ev('X'), Ev('Y'), ]); return $obj; }