Hi, I''m using a Wx::GridCellChoiceEditor within a Wx:grid. I have it displaying as it should, but I now need to do something when a user selects a string. The only likely looking event I can find is evt_grid_cell_change. evt_grid_cell_change is calling the method I defined when I click off the choice box, assuming the choice changed. This is fine. What I need to do, is get the newly selected item (or preferably some client data asssociated with it) how do I do that? I can''t see any likley methods, and inspecting the generated event is useless.... I currently have: # Set up the event evt_grid_cell_change {|event| cell_change(event)} #Set up the rows, there is more to this, but it''s just putting values in cells... @characters.each do |char| weapons = Wx::GridCellChoiceEditor.new(char.weapons_list) @grid.insert_rows @grid.set_cell_editor(0,1,weapons) end #The method run when the selection changes def cell_change(event) row = event.get_row character = Character.find_by_name(@grid.get_cell_value(row,0)) character.held_weapon = ??? end What do I need to put in the ??? . As I said, ??? should ideally be the string selected, or some data associated with it.... Thanks Anthony _______________________________________________ wxruby-users mailing list wxruby-users@rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
Anthony Metcalf
2009-Nov-24 15:19 UTC
[wxruby-users] Wx::GridCellChoiceEditor get selected string
I re-read my email when it hit the list. I noticed a bit of code on the line above where I was asking about, and thought, I wonder.... Turns out I was seriously over thinking it.... def cell_change(event) row = event.get_row character = Character.find_by_name(@grid.get_cell_value(row,0)) character.held_weapon = @grid.get_cell_value(row,1) end Does the trick quite nicely. Doh. A -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 262 bytes Desc: OpenPGP digital signature URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20091124/69f35613/attachment.bin>