Forum: wxRuby Re: ListCtrl.get_selections broken?

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.
Alex F. (Guest)
on 2009-03-11 15:57
(Received via mailing list)
Christian - you didn't say, but I'm assuming you're working on Windows
b/c I now tried it there and can reproduce the problem.

I've no idea why Windows differs here, but fortunately it's easy to fix.
The definition of get_selections is in Ruby and is in
lib/wx/classes/listctrl.rb. If you want the definition that works on
Windows, add something like this to your script:

class Wx::ListCtrl
  def get_selections
    selections = []
    item = get_next_item(-1, Wx::LIST_NEXT_ALL, Wx::LIST_STATE_SELECTED)
    while item >= 0
      selections << item
      item = get_next_item(item, Wx::LIST_NEXT_BELOW,
Wx::LIST_STATE_SELECTED)
    end
    selections
  end
end

The only change is Wx::LIST_NEXT_ALL was previously LIST_NEXT_BELOW.

I'll apply this to wxRuby once I've tested on other platforms. Thanks
again for the report.

a
Christian S. (Guest)
on 2009-03-12 23:42
Hi Alex,

you're right, I'm working on Win XP - hence your workaround fixed it for
me.
Btw.: It's me who has to thank you again for your great help!

Thank you for making wxRuby and also for providing such a great support!

Christian.


Alex F. wrote:
> Christian - you didn't say, but I'm assuming you're working on Windows
> b/c I now tried it there and can reproduce the problem.
>
> I've no idea why Windows differs here, but fortunately it's easy to fix.
> The definition of get_selections is in Ruby and is in
> lib/wx/classes/listctrl.rb. If you want the definition that works on
> Windows, add something like this to your script:
>
> class Wx::ListCtrl
>   def get_selections
>     selections = []
>     item = get_next_item(-1, Wx::LIST_NEXT_ALL, Wx::LIST_STATE_SELECTED)
>     while item >= 0
>       selections << item
>       item = get_next_item(item, Wx::LIST_NEXT_BELOW,
> Wx::LIST_STATE_SELECTED)
>     end
>     selections
>   end
> end
>
> The only change is Wx::LIST_NEXT_ALL was previously LIST_NEXT_BELOW.
>
> I'll apply this to wxRuby once I've tested on other platforms. Thanks
> again for the report.
>
> a
This topic is locked and can not be replied to.