Ah, now I understand. I did not consider the points you bring up. Now  
I know better. I'm both a Ruby and a Tk newbie, so I'm glad to get  
advice from an expert.

Thank you very much. I will heed your advice.

Regards, Morton

On Jul 28, 2006, at 6:03 PM, Hidetoshi NAGAI wrote:

> From: Morton Goldberg <m_goldberg / ameritech.net>
> Subject: Re: Ruby::Tk on OS X event binding hint
> Date: Sat, 29 Jul 2006 04:58:52 +0900
> Message-ID: <BF26EC2E-BDF2-4875-9C7E-D60FA9037A9D / ameritech.net>
>>> It will not work on other toplevel widgets.
>>> The following may be better.
>>> ----------------------------------------
>>> ev = TkVirtualEvent.new
>>> ev.add('Command-q')
>>> ev.add('Command-Shift-q') ### or ev.add('Command-q', 'Command-Shift-
>>> q')
>>> TkBindTag::ALL.bind(ev){exit}
>>> ----------------------------------------
>>
>> Are you saying that, when my code runs, Command-q keystroke events
>> will trigger the callback only when the main window (Tk.root) is the
>> active window? Or is the problem that I've used two calls to bind
>> when I should have used just one? Or is it something else?
>
> I'm sorry if I misunderstanded your post.
> When your application has two or more windows, your binding will work
> on the root widget (or widgets on the root widget) only.
> Of course, you are right if that is what you want.
> The bindtags list of the widget on the other toplevel widget doesn't
> include the root widget.
> Please see Tcl/Tk's manual of `bindtags'.
>
>>> ev = TkVirtualEvent.new
>>> ev.add('Button-2', 'Control-Button-1')
>>> Tk.root.bind(ev){|e| info_mnu.popup(e.root_x, e.root_y)}
>>
>> Again I ask for further explanation: What problem arises with the
>> original code that you are fixing? (My code seems to be working with
>> no problems in my application, but that app has only one window.) In
>> this case it looks as if the two separate calls to bind are what
>> bother you.
>
> "Don't Repeat Yourself" to prevent bugs. ;-)
> If the part (and events for the callback) never change in the life
> cycle of your software, it has no problem.
> -- 
> Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp)
>