# Re: ListCtrl.get\_selections broken?

**URL:** <https://www.ruby-forum.com/t/re-listctrl-get-selections-broken/162575>\
**Category:** wxRuby\
**Created:** [March 11, 2009, 2:57pm UTC](https://www.ruby-forum.com/t/re-listctrl-get-selections-broken/162575 "2009-03-11T14:57:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![absolute-beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@absolute-beginner](https://www.ruby-forum.com/u/absolute-beginner)\
**Post date:** [March 11, 2009, 2:57pm UTC](https://www.ruby-forum.com/t/re-listctrl-get-selections-broken/162575/1 "2009-03-11T14:57:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![absolute-beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@absolute-beginner](https://www.ruby-forum.com/u/absolute-beginner)\
**Post date:** [March 12, 2009, 10:42pm UTC](https://www.ruby-forum.com/t/re-listctrl-get-selections-broken/162575/2 "2009-03-12T22:42:15Z")

</div>

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
