Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

close (unpost) Tk::Menu widget on mousbutton release

by ldln (Pilgrim)
on Apr 18, 2006 at 19:39 UTC ( [id://544168]=perlquestion: print w/replies, xml ) Need Help??

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

Why won't the menu close on mousebutton release? Want musebutton press to show the popup menu and mousebutton release to unpost it? Why doesn't this work?
use strict; use Tk; my $mw = tkinit; my $mb = $mw->Menubutton(-text=>'menubutton', )->pack; my $menu = $mb->Menu ( -tearoff=>0, -menuitems => [ ['command',' item', ] ] ); #no diff #$menu->bindtags(undef); $mb->bind('<Button-1>' => sub { print "\nButtonpress - post menu"; my ($x,$y) = ($Tk::event->X,$Tk::event->Y); $menu->post($x,$y); }); $mb->bind('<ButtonRelease>' => sub { print "\nunpost menu."; #no diff #$menu->grabRelease; $menu->unpost(); }); MainLoop;

Replies are listed 'Best First'.
Re: close (unpost) Tk::Menu widget on mousbutton release
by zentara (Archbishop) on Apr 18, 2006 at 19:43 UTC
    It works here on linux, Tk-804.027, Perl-588

    I'm not really a human, but I play one on earth. flash japh
      Thanks, I guess. Yes, I tried it on fedora just now and the popup thingy worked..but there were other issues, some garbage "noise" graphics appeared under the button text..maybe some KDE issue, whatever, cos it really doesn't help me since I'm on win32 (perl5.8.7|Tk804.027)..

      I don't know how many times things like this have happend to me with Tk. I have to stop, bang my head against the wall and start reinventing the wheel to get something that should be working to work..in some roundabout way..and I'm starting to get oh so tired of it..

      I love Tk, I really do, but I think it might be time to move on to something else soon. The "RAD factor" is not that huge with Tk when things are broken all the time. Endof rant. (tired).

        Ha ha. Yeah, blame Tk, and threaten to use something else. They always come back :-) Why not blame Microsoft, and threaten to dump them? Things are always harder to do on Win32.

        Tk make doing most things very easy, so for 95% of all projects, it's easiest to do in Tk. I was getting fed up like you, thought, " yeah I'll switch to Gtk2", then I find out that Gtk2 has it's share of problems, and while it gives you alot of control, you spend much more more time setting up and figuring out the signal chains. Then try to figure out settings colors in Gtk2..... it's so easy in Tk. So "6 of one, half dozen of the other".


        I'm not really a human, but I play one on earth. flash japh
Re: close (unpost) Tk::Menu widget on mousbutton release
by injunjoel (Priest) on Apr 18, 2006 at 20:17 UTC
    Greetings,
    You might want to have a look at the list of Event Types in Tk.

    -InjunJoel
    "I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo
      Yes yes, I read those already..Have I choosen some kind of illegal event types combination? Those docs doesn't mention anything bout special cases with menus...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://544168]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (1)
As of 2024-04-25 03:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found