[wxruby-users] ListCtrl.get_selections broken?

Christian Schmidt lists at ruby-forum.com
Sat Mar 7 20:19:44 EST 2009


Hi again,

may it be that ListCtrl.get_selections is broken? Or did I misunderstand
sth. in the docs?

I'm always getting 0 as the size of the returned array while
get_selected_item_count is reporting the correct number.

See the attachment or the following lines for a program that
demonstrates this.


require 'wx'
include Wx

class MyFrame < Frame
  def initialize
    super nil, -1, "ListCtrl Error"

    @list = ListCtrl.new(self, -1, DEFAULT_POSITION, DEFAULT_SIZE,
LC_REPORT)
    @list.insert_column(0, 'abc')

    li = ListItem.new()
    li.set_state LIST_STATE_SELECTED

    li.set_text '123'
    @list.insert_item(li)
    li.set_text '234'
    @list.insert_item(li)
    li.set_text '345'
    @list.insert_item(li)
    li.set_text '456'
    @list.insert_item(li)


    puts @list.get_selected_item_count # --> 4
    puts @list.get_selections.size     # --> 0
  end
end

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

MyApp.new.main_loop


I hope I'm doing something wrong.

Cheers,
Christian.

Attachments:
http://www.ruby-forum.com/attachment/3407/ListCtrl_Err_demo.rb.rb

-- 
Posted via http://www.ruby-forum.com/.


More information about the wxruby-users mailing list