Re: ListCtrl.get_selections broken?


#1

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


#2

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