From: Josef Wolf Date: 2006-09-06T03:00:25+09:00 Subject: Re: How to properly bind context menus to canvas in Ruby/Tk? On Tue, Sep 05, 2006 at 08:43:01PM +0900, Morton Goldberg wrote: Thanks for the reply, Morton! > I tried running your code on my system which is OS X 10.4.7 running > Ruby 1.8.2, and I don't see what you report. What I see is following: > > * Right-clicking away from the the rectangle, the canvas' contextual > menu pops-up. > * Right-clicking on the rectangle. > ** The rectangle's contextual menu pops-up. > ** When the rectangle's menu is dismissed, the canvas' > contextual menu pops-up. How do you "dismiss" the menu? Whatever I do, I never get the second menu. > With a small tweak, I was able to keep the canvas' contextual menu > from popping up when the the rectangle is right-clicked. So what I > have now running on my system works as you expected. Your handled_by_rect flag seems to do the trick. But this would be a global flag in my case since the menus are created from different classes. :-( I would like to avoid such a global flag. The Tk::Bind manpage mentions that processing of matching callbacks can be controlled by "return" or calling "Tk->break" inside the callback. That is, the rectangle's callback should call Tk->break. But none of the involved classes seem to have a break method. And returning false/true/nil/1/0 don't have any effect, too. Any ideas?