Re: [Fxruby-users] FXTable manipulation
Status: Inactive
Brought to you by:
lyle
|
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
|