From: "Michael C. Libby" Date: 2002-12-11T10:06:56+09:00 Subject: FXRuby, MDI window switching -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I have an FXMDIClient widget for which I would like to detect changes in active window so that I can modify root-level keybindings and change the menus available. I am having trouble capturing the SEL_CHANGED message in the FXMDIClient or the SEL_ACTIVATED messages in the child widgets. Here is my sample code, which crashes pretty hard when I try to switch windows: #!/usr/bin/ruby -w require 'fox' include Fox def new_buffer(root,x) mdi_child = FXMDIChild.new(root, "Test", nil, nil, 0, (25 * x), (25 * x), 400, 300) FXText.new(mdi_child, nil, 0) mdi_child.create end def switch_buffer(sender, sel, data) puts "sender: #{sender}\nsel: #{sel}\ndata: #{data}" end #create app app = FXApp.new mw = FXMainWindow.new(app, "mdi_test", nil, nil, DECOR_ALL, 0, 0, 640, 480) buffers = FXMDIClient.new(mw, LAYOUT_FILL_X|LAYOUT_FILL_Y) app.create mw.show 3.times{|x| new_buffer(buffers, x) } buffers.connect(SEL_CHANGED, method(:switch_buffer)) app.run The output: m_libby@greyhound:~$ ruby mdi_error.rb sender: # sel: 2555904 data: # mdi_error.rb:27:in `position': undefined method `position' for nil (NoMethodError) from mdi_error.rb:27:in `run' from mdi_error.rb:27 m_libby@greyhound:~$ I've tried tinkering with the block version of connect, and putting in return values from the switch_buffer method, but I still get errors either way. Any ideas? ruby 1.7.3 FOX 1.0.28 FXRuby 1.0.16 Thanks. -michael -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE99o8m4ClW9KMwqnMRAi6CAKCr9dXYkA33dA1cwrIYKCUlENs7YQCfQzbC 4DaNefEUt+Yu3EQA31aesr4= =XHk1 -----END PGP SIGNATURE-----