FXRuby, MDI window switching

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: #Fox::FXMDIClient:0x40ec61b4
sel: 2555904
data: #Fox::FXMDIChild:0x40ec53e0
mdi_error.rb:27:in position': undefined methodposition’ 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 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.

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?

The code looks OK; this sounds like a bug. I was getting ready to put
together a new FXRuby release anyways and so I’ll try to track this one
down first.

···

On Wed, 11 Dec 2002 10:06:56 +0900, Michael C. Libby wrote:

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.
[snip]
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?

The code looks OK; this sounds like a bug. I was getting ready to put
together a new FXRuby release anyways and so I’ll try to track this one
down first.

Thanks Lyle! Glad to know that, for once, my ability to read and understand
the Fine Manual was not at fault. This seems to work fine in your latest
code.

-michael

···

On Wednesday 11 December 2002 10:19, Lyle Johnson wrote: