Event-Issue with TreeCtrl with "TR_MULTIPLE"


#1

Hi,

I’ve yet another issue with my favourite toolkit.

When I’m adding a TreeCtrl that has the TR_MULTIPLE style set, the event
“evt_tree_sel_changed” most oftenly gets fired multiple times (whereas a
TreeCtrl with single selection only fires once - as expected). The
exception is the automatic root-selection at program startup and when
I’m widening or narrowing the selected nodes holding ctrl and using the
cursor keys.

See the attachment or below for an example how to reproduce this.
I’m working on WinXP, wxRuby 2.0.0, ruby 1.8.6

require ‘wx’
include Wx

class MyFrame < Frame
def initialize
super nil, -1, “Tree: select-event error?”

@tree = TreeCtrl.new(self, -1, :style => TR_MULTIPLE)
@root = @tree.add_root 'root', 0

['one', 'two', 'three', 'four'].each do |i| add i end
@tree.expand @root

@num_sels = 0

evt_tree_sel_changed(@tree) do |e|
  @num_sels += 1
  puts "sel event #{@num_sels}"
end

end

def add item
node = @tree.insert_item @root, 0, item, 1
child = @tree.insert_item node, 0, “child”, 2
@tree.insert_item child, 0, “grand-child”, 2
@tree.expand node
@tree.expand child
end
end

class MyApp < App
def on_init
f = MyFrame.new
f.show
end
end

MyApp.new.main_loop

Thanks in advance for any hint,
Christian.