matthias / kl-mailer.de skrev:
> Hi list,
>
> i'm working on gui using ruby/tk.
> Everything went fine (exept the poor documentation), but now i have a
> problem with submenus. A small example-code to demonstrate the issue:
>
> menu = TkMenu.new
> menu.add_command('label' => 'Foo', 'command' => lambda { p "foo" })
> sub = TkMenu.new
> sub.add_command('label' => 'Bar', 'command' => lambda { p "bar" })
> menu.add_cascade('label' => 'submenu', 'menu' => sub)
>
> canvas = TkCanvas.new
> canvas.bind('1') {|e| menu.popup e.x_root, e.y_root}
> canvas.pack
>
> Tk.mainloop
>
> The code works nearly as expected, menu appears an has correct content.
> If i click on "Foo", text "foo" is written to the console, but if i
> click on
> "Bar" nothing happens :(
> Any idea what's going wrong?
>
> Ruby: ruby 1.8.5 (2006-08-25) [i486-linux]
> Linux: Linux version 2.6.12 (root@louipaz) (gcc version 3.3.6 (Debian
> 1:3.3.6-13))
>
> thanks a lot,
> Matthias
Tested your code (just added require 'tk' as first line) with
Ruby 1.8.5 on WinXP and Active State Tcl 8.4.13.

No problem, works fine, both "foo" and "bar" printed as
they should. Maybe your Tcl needs updating?