Thread: [Fxruby-users] FXTable manipulation
Status: Inactive
Brought to you by:
lyle
From: Tom <tku...@so...> - 2003-12-29 20:19:02
|
Hi, I'm a newbie to fox and FXRuby. I have 3 table problems I can't solve: 1.) I'd like to turn off the ability to select particular cells, ie the equivalent of FXTableItem.disable(). I attempt to use "disable" but keep getting the error that it's an unknown method. 2.)I'd also to make it so that a click on any cell in a row selects that entire row. 3.) I can't seem to figure out how to tell a particular FXTableItem how to respond to events. What I have is a table, and several buttons outside of the table. When the user dbl-clicks a cell, I want it to be the same thing as selecting a particular cell and hitting my "edit" button. I've grepped my way through the fox docs, hoping to find a way to do what I need to do, but to no avail. Any help or pointers to help will be greatly appreciated, Tom |
From: Lyle J. <jl...@cf...> - 2003-12-29 22:27:44
|
Tom wrote: > I'm a newbie to fox and FXRuby. I have 3 table problems I can't solve: > > 1.) I'd like to turn off the ability to select particular cells, ie the > equivalent of FXTableItem.disable(). I attempt to use "disable" but keep > getting the error that it's an unknown method. There's no direct way to disable table items, but you can intercept the SEL_LEFTBUTTONPRESS and SEL_LEFTBUTTONRELEASE messages that the FXTable sends to its target in order to ignore mouse clicks on certain cells, e.g. # Catch left-button press from table @table.connect(SEL_LEFTBUTTONPRESS) do |sender, sel, event| # Get row and column for clicked cell row = @table.rowAtY(event.win_y) col = @table.colAtX(event.win_x) # If this cell is enabled, return zero (i.e. have the # block evaluate to zero) so that the table's normal # processing of the left-button press event will kick in. # If this cell is disabled, return non-zero to indicate # that we've completely handled the event; in this case, # the cell shouldn't get "selected". # result = tableItemEnabled(row, col) ? 0 : 1 end # Catch left-button release from table @table.connect(SEL_LEFTBUTTONRELEASE) do |sender, sel, event| # Get row and column for clicked cell row = @table.rowAtY(event.win_y) col = @table.colAtX(event.win_x) # If this cell is enabled, return zero (i.e. have the # block evaluate to zero) so that the table's normal # processing of the left-button press event will kick in. # If this cell is disabled, return non-zero to indicate # that we've completely handled the event; in this case, # the cell shouldn't get "selected". # result = tableItemEnabled(row, col) ? 0 : 1 end > 2.)I'd also to make it so that a click on any cell in a row selects that > entire row. Something like this should work: @table.connect(SEL_COMMAND) do |sender, sel, tablePos| @table.setAnchorItem(tablePos.row, 0) @table.extendSelection(tablePos.row, @table.numCols-1, true) end > 3.) I can't seem to figure out how to tell a particular FXTableItem how > to respond to events. What I have is a table, and several buttons > outside of the table. When the user dbl-clicks a cell, I want it to be > the same thing as selecting a particular cell and hitting my "edit" button. Something like this should work: @table.connect(SEL_DOUBLECLICKED) do |sender, sel, tablePos| editThisCell(tablePos.row, tablePos.col) end Hope this helps, Lyle |
From: Tom <tku...@so...> - 2003-12-30 18:59:56
|
Lyle, Thanks a ton. These solutions worked great. BTW, Is there a way to set font color for a particular cell? Thanks, Tom Lyle Johnson wrote: > Tom wrote: > >> I'm a newbie to fox and FXRuby. I have 3 table problems I can't solve: >> >> 1.) I'd like to turn off the ability to select particular cells, ie >> the equivalent of FXTableItem.disable(). I attempt to use "disable" >> but keep getting the error that it's an unknown method. > > > There's no direct way to disable table items, but you can intercept > the SEL_LEFTBUTTONPRESS and SEL_LEFTBUTTONRELEASE messages that the > FXTable sends to its target in order to ignore mouse clicks on certain > cells, e.g. > > # Catch left-button press from table > @table.connect(SEL_LEFTBUTTONPRESS) do |sender, sel, event| > # Get row and column for clicked cell > row = @table.rowAtY(event.win_y) > col = @table.colAtX(event.win_x) > > # If this cell is enabled, return zero (i.e. have the > # block evaluate to zero) so that the table's normal > # processing of the left-button press event will kick in. > # If this cell is disabled, return non-zero to indicate > # that we've completely handled the event; in this case, > # the cell shouldn't get "selected". > # > result = tableItemEnabled(row, col) ? 0 : 1 > end > > # Catch left-button release from table > @table.connect(SEL_LEFTBUTTONRELEASE) do |sender, sel, event| > # Get row and column for clicked cell > row = @table.rowAtY(event.win_y) > col = @table.colAtX(event.win_x) > > # If this cell is enabled, return zero (i.e. have the > # block evaluate to zero) so that the table's normal > # processing of the left-button press event will kick in. > # If this cell is disabled, return non-zero to indicate > # that we've completely handled the event; in this case, > # the cell shouldn't get "selected". > # > result = tableItemEnabled(row, col) ? 0 : 1 > end > >> 2.)I'd also to make it so that a click on any cell in a row selects >> that entire row. > > > Something like this should work: > > @table.connect(SEL_COMMAND) do |sender, sel, tablePos| > @table.setAnchorItem(tablePos.row, 0) > @table.extendSelection(tablePos.row, @table.numCols-1, true) > end > >> 3.) I can't seem to figure out how to tell a particular FXTableItem >> how to respond to events. What I have is a table, and several >> buttons outside of the table. When the user dbl-clicks a cell, I >> want it to be the same thing as selecting a particular cell and >> hitting my "edit" button. > > > Something like this should work: > > @table.connect(SEL_DOUBLECLICKED) do |sender, sel, tablePos| > editThisCell(tablePos.row, tablePos.col) > end > > Hope this helps, > > Lyle |
From: Lyle J. <jl...@cf...> - 2003-12-30 19:39:07
|
Tom wrote: > Thanks a ton. These solutions worked great. BTW, Is there a way to set > font color for a particular cell? Ummm, answered that question on this mailing list just yesterday, Tom ;) |
From: Tom <tku...@so...> - 2003-12-30 19:42:59
|
DOH! Sorry... Got it. I'll use the stippling to highlight it instead. Tom Lyle Johnson wrote: > Tom wrote: > >> Thanks a ton. These solutions worked great. BTW, Is there a way to >> set font color for a particular cell? > > > Ummm, answered that question on this mailing list just yesterday, Tom ;) > > |