Forum: wxRuby No evt_tree_sel_changed with TR_MULTIPLE

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6da9d2e5648516c14c32c2103eaf4293?d=identicon&s=25 Christian Schmidt (raskolnikov)
on 2009-03-23 23:41
Attachment: tree_no_selection_evt.rb (517 Bytes)
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.
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2009-03-24 08:29
(Received via mailing list)
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:
http://trac.wxwidgets.org/ticket/9570

> 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_...

a
This topic is locked and can not be replied to.