From: Lyle Johnson Date: 2002-11-05T02:40:24+09:00 Subject: Re: Fun with FX ruby.... -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Mark Krell wrote: | I'm want to dynamicly add.delete rows to a table using | FX ruby, but I'm running into some difficulty. | | In My dialog I have a connect for when I click an item | in my table | | @table.connect(SEL_COMMAND, method(:push)) | | which runs this method (It looks in Col 4 for the | "add" button, adds a row, and changes the button to | delete. If it's delete, the delete the row) | I'm sure I'm using FXTable::ID_INSERT_ROW and | FXTable::ID_DELETE_ROW incorrectly, how do you use it | correctly? How do you delete the row you are currently | clicking on? FXTable::ID_INSERT_ROW and FXTable::ID_DELETE_ROW are just constants used as message identifiers -- they aren't themselves methods that you can call directly. The most straightforward way for you to do this from Ruby code is to just call the insertRows() or removeRows() methods directly on the FXTable: ~ def push(theTable, sel, currentPos) ~ row = ptr.row ~ col = ptr.col ~ return if row == 0 ~ if col == 4 ~ if @table.getItem(row, col).to_s == "Add" ~ @table.setItemText(row, 4, "Delete") ~ @table.insertRows(row, 1) ~ @table.setItemText(row, 0, row.to_s) ~ @table.getItem(row, 0).setButton(true) ~ @table.getItem(row, 0).justify = 0 ~ @table.setItemText(row, 4, "Add") ~ @table.getItem(row, 4).setButton(true) ~ @table.getItem(row, 4).justify = 0 ~ elsif @table.getItem(row, col).to_s == "Delete" ~ @table.removeRows(row, 1) ~ end ~ end ~ end Hope this helps, Lyle -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQE9xrABRy8FwLkdsRcRAvL/AJ92opPMBqJVfPufgRQpnQ0KZ1WY9ACfdyuH gxGEeS3H3oTvR35jopJmXk0= =22IQ -----END PGP SIGNATURE-----