This example shows how to add new behavior in all tables so that users can double-click to edit a cell, toggle a boolean value, and select/deselect an entire table.
response to table on button1 double click
# Double clicked on a cell, if not readonly
# then edit it or toggle boolean value.
if (xcoord != 0 and ycoord != 0) then
if (xcoord != xcursor of object or
ycoord != ycursor of object) then
# This case only happens if they double clicked
# on a column resize line at a different location
# than the cell cursor, so go to that cell first.
change object cursor to (xcoord) (ycoord)
end if
# Only change cells or put in edit mode
# if the table and column are not readonly.
if (not (object is readonly or
column (xcoord) of object is readonly)) then
# Edit cell, if not a boolean column
if (type of column (xcoord) of object != "boolean") then
make object edit
else # Toggle if a boolean column
copy not (boolean cell (xcoord), (ycoord) of object)
to cell (xcoord), (ycoord) of object
end if
end if
# If the user double-clicks on an empty space (not a cell, row, or
# column), toggle select/deselect all.
else if (xcoord = 0 and ycoord = 0) then
if ( (selected rows of object +
selected columns of object) > 0 ) then
deselect object
else # Nothing selected, so select all.
select object
end if
# Double-clicked on a row header
else if (xcoord = 0 and ycoord != 0) then
# Fill in desired row behavior
# Double-clicked on a column header
else # (xcoord != 0 and ycoord = 0)
# Fill in desired column behavior
end if
end if
end if