thanks for the reply. The problem appears to be that, once the editor is
instantiated, the grid will receive the wheel events everywhere except
where the editor is visible.
I would have expected (a) to work - mouse events are fired on whichever
is the topmost control where the mouse is. For an editor control, the
mouse pointer may not be on top of the control itself.
it would appear that is the case - which may be why the grid receives
the wheel events but not the editor.
Does the evt_mousewheel fire correctly if you have it as a constant
event handler for the Grid?
yes
You could try using the method Window#capture_mouse to force mouse input
to be directed to a particular window - either the grid or the editor
control - to see if this helps.
I will have to try that - digging into it now.
Failing that, please post a complete, runnable but minimal example with
the problem and I’ll see if I can help
attached. I will let you know as soon as I found out anything regarding
the capture_mouse method.
tony
(I’m getting an “application error” from the webserver when I try to
attach a file so I’m adding it here and reporting the bug to the
webmaster)
#!/usr/bin/env arch -i386 ruby
begin
require ‘rubygems’
rescue LoadError
end
require ‘wx’
class MyGridTable < Wx::GridTableBase
attr_reader :cols, :rows
def initialize(rows, cols)
super()
@rows = rows
@cols = cols
end
def get_number_rows
@rows
end
def get_number_cols
@cols
end
def get_value(row, col)
(col + @cols * row).to_s
end
def get_attr(row, col, attr_kind)
Wx::GridCellAttr.new
end
def is_empty_cell(row, col)
false
end
def set_value(x, y, val)
puts “Attempting to change cell (#{x}, #{y}) to ‘#{val}’”
end
def get_type_name(row, col)
“FOOBAR”
end
end
class MyEditor < Wx::GridCellChoiceEditor
def initialize
super([‘7’,‘13’,‘23’,‘42’])
end
def begin_edit row, col, grid
puts “begin edit”
grid.evt_mousewheel {|e| on_wheel e }
super
end
def on_wheel event
p event
end
def end_edit(row, col, grid)
puts “end edit”
# TODO: how to unsubscribe?
super
end
end
class GridFrame < Wx::Frame
def initialize()
super(nil, :title => ‘Mousewheel example’, :size => [600, 300])
main_sizer = Wx::VBoxSizer.new
@grid = Wx::Grid.new(self)
@grid.register_data_type( "FOOBAR",
Wx::GridCellStringRenderer.new,
MyEditor.new )
@grid.table = MyGridTable.new(10, 10)
main_sizer.add(@grid, 1, Wx::EXPAND|Wx::ALL, 5)
self.sizer = main_sizer
end
end
Wx::App.run do
GridFrame.new.show
end