From: Chris Alfeld Date: 2006-04-14T05:34:49+09:00 Subject: ruby/tk HTML_Widget and href's Consider the following goal: * Parse the html "click me" and display. * Detect user clicks convert to href. The following code does *not* work: ---- require 'tk' require 'tkextlib/tkHTML' def do_click(s) puts s + "\n" end html = Tk::HTML_Widget.new(TkRoot.new,'hyperlinkcommand'=>proc {|s| do_click(s)}) html.parse("click me") html.pack Tk.mainloop ---- The following code does work but is rather inelgant (note the Tk.bind): ---- require 'tk' require 'tkextlib/tkHTML' def do_click(x,y) href = $HTML.href(x,y)[0] print href + "\n" if href end $HTML = Tk::HTML_Widget.new(TkRoot.new) Tk.bind($HTML.path + ".x",'1',proc {|x,y| do_click(x,y)},"%x %y") $HTML.parse("click me") $HTML.pack Tk.mainloop ---- Does anyone know what the 'hyperlinkcommand' property of HTML_Widget does? Anyone have other ways to make clicking on hyperlinks work? BTW, HTML_Widget corresponds (at least on my system) to tkHTML 2.0. c.