From: Morton Goldberg <m_goldberg / ameritech.net>
Subject: Ruby::Tk on OS X event binding hint
Date: Fri, 28 Jul 2006 21:42:49 +0900
Message-ID: <845517A3-24D0-413E-9493-8F86D4B02902 / ameritech.net>
> 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}
----------------------------------------

> 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)}

-- 
Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp)