# No evt\_tree\_sel\_changed with TR\_MULTIPLE

**URL:** <https://www.ruby-forum.com/t/no-evt-tree-sel-changed-with-tr-multiple/163690>\
**Category:** wxRuby\
**Created:** [March 23, 2009, 11:41pm UTC](https://www.ruby-forum.com/t/no-evt-tree-sel-changed-with-tr-multiple/163690 "2009-03-23T23:41:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![caefer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e36b37/32.png) [@caefer](https://www.ruby-forum.com/u/caefer)\
**Post date:** [March 23, 2009, 11:41pm UTC](https://www.ruby-forum.com/t/no-evt-tree-sel-changed-with-tr-multiple/163690/1 "2009-03-23T23:41:40Z")

</div>

Hi,

I have a problem with evt\_tree\_sel\_changed not getting fired when I’m  
selecting a node programatically on a TreeCtrl with the TR\_MULTIPLE flag  
set.  
Is this intended?

I’ve got some code depending on the evt-handler.  
Can I work around this? I thought of EvtHandler#add\_pending\_event but I  
can’t figure out the correct commandType parameter to TreeEvent#new.

Here’s a sample app, that demonstrates the above:

require ‘wx’  
include Wx

class MyFrame \< Frame  
def initialize  
super nil, -1, “no sel event”

```
@tree = TreeCtrl.new(self, -1, :style => TR_MULTIPLE)

evt_tree_sel_changed(@tree) do |e|
  puts "sel changed #{@tree.get_item_text(e.get_item)}"
end

@root = @tree.add_root 'root', 0
child = @tree.insert_item @root, 0, 'child'
@tree.expand @root

@tree.select_item child

```

end  
end

class MyApp \< App  
def on\_init  
f = MyFrame.new  
f.show  
end  
end

MyApp.new.main\_loop

Thanks in advance,  
Christian.

---

<div class="post-metadata">

**Author:** ![caefer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e36b37/32.png) [@caefer](https://www.ruby-forum.com/u/caefer)\
**Post date:** [March 24, 2009, 8:29am UTC](https://www.ruby-forum.com/t/no-evt-tree-sel-changed-with-tr-multiple/163690/2 "2009-03-24T08:29:07Z")

</div>

Hi Christian

Christian Schmidt wrote:

> I have a problem with evt\_tree\_sel\_changed not getting fired when I’m  
> selecting a node programatically on a TreeCtrl with the TR\_MULTIPLE flag  
> set.

I think it’s a wxWidgets bug:

> **[wxTrac has been migrated to GitHub Issues - wxWidgets](https://wxwidgets.org/develop/how-to-report-issues/trac-migration/)**

> I’ve got some code depending on the evt-handler.  
> Can I work around this? I thought of EvtHandler#add\_pending\_event but I  
> can’t figure out the correct commandType parameter to TreeEvent#new.

The event type is an integer constant which uniquely identifies that  
kind of event. In this case, you want Wx::EVT\_COMMAND\_TREE\_SEL\_CHANGED.

For reference, you can see the mapping of all event types to event  
classes in lib/wx/classes/evthandler.rb

[http://wxruby.rubyforge.org/svn/branches/wxruby\_2\_0\_stable/lib/wx/classes/evthandler.rb](http://wxruby.rubyforge.org/svn/branches/wxruby_2_0_stable/lib/wx/classes/evthandler.rb)

a
