Morton Goldberg
7/28/2006 7:59:00 PM
Thank you for your comments. However, I'm pretty new to Ruby Tk, and
I need further explanation to help me understand them.
On Jul 28, 2006, at 12:05 PM, Hidetoshi NAGAI wrote:
>> On Macintosh OS X, one can use 'Command' and 'Option' as Tk event
>> type modifiers to get Command and Option key shortcuts. For example,
>>
>> Tk.root.bind('Command-q') {exit}
>> Tk.root.bind('Command-Q') {exit}
>
> 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?
>> will give the normal quit-key behavior. Also, if info_mnu is an
>> instance of TkMenu,
>>
>> Tk.root.bind('Button-2') {|e| info_mnu.popup(e.root_x, e.root_y)}
>> Tk.root.bind('Control-Button-1') {|e| info_mnu.popup(e.root_x,
>> e.root_y)}
>>
>> will make info_mnu into a contextual menu. The first binding will
>> serve users with a two- or three-button mouse and the second will
>> serve those with a one-button mouse.
>
> 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.
> --
> Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
Regards, Morton