Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Perl Monks,
if i right click the mouse i can see some options like open,copy,cut,paste,delete in windows
how to enble the mouse right click options in Tk window if i open How to add new option to that
please suggest me
  • Comment on How to add new options when i right click in TK Window

Replies are listed 'Best First'.
Re: How to add new options when i right click in TK Window
by zentara (Cardinal) on Sep 17, 2008 at 16:40 UTC
    It often depends on what widget you are using and what is focused at the time of the right-click. Some widgets will have built-in bindings for different mouse clicks, like the Tk::Text widget. Play with this, and notice the difference when you uncomment the line Tk::break.
    #!/usr/bin/perl use warnings; use Tk; use strict; my $main = new MainWindow; $main->geometry('200x200'); $main->Button(-text=>"click",-command=>sub{ print "Button left click\n"; })->pack; $main->bind('Tk::Button', '<ButtonRelease-3>', \&some_sub); $main->bind('<ButtonRelease-3>', \&some_other_sub); MainLoop; sub some_sub{ print 'Button ',scalar gmtime,"\n"; #Tk::break; #stops the main window binding from activating } sub some_other_sub{ print 'main window ',scalar gmtime,"\n"; }

    I'm not really a human, but I play one on earth Remember How Lucky You Are
Re: How to add new options when i right click in TK Window
by Anonymous Monk on Sep 17, 2008 at 14:54 UTC