Table Modification

Geoff Canyon gcanyon at inspiredlogic.com
Thu Jan 26 04:12:57 EST 2006


Bill Vlahos and I were having dinner when the subject of tables came  
up. We agreed that it would be nice to have a way to limit the number  
of columns in the Rev table object. Between finishing the food and  
paying the check we hacked this together. It's not the most elegant  
solution, but it seems to work.

First, note that this involves hacking the Revolution frontscript  
that controls tables, so take that as a caution. I take no  
responsibility if this causes damage. Make a backup of the  
development environment before trying this. Don't work on any of your  
critical projects until you're confident this is working correctly.  
Wear a grounding strap while performing this procedure. Remember to  
wear something warm, and pack a lunch.

1. Open the message box.
2. Click on the frontscripts button
3. If it isn't already, check "Show Revolution UI Frontscripts"
4. Click revTable.
5. Click the Edit Script button.
6. In the script, locate the revMoveCellRight handler.
7. Insert the following code at the beginning of the handler:

   if the cREVTable["maxColumnCount"] of lObject is a number \
       and the cREVTable["currentxcell"] of lObject \
       >= the cREVTable["maxColumnCount"] of lObject then
     lock screen
     repeat the cREVTable["currentxcell"] of lObject - 1
       revMoveCellLeft
     end repeat
     revMoveCellDown
     unlock screen
     exit revMoveCellRight
   end if

It should look like this when you're done:

on revMoveCellRight
   if the cREVTable["maxColumnCount"] of lObject is a number \
       and the cREVTable["currentxcell"] of lObject \
       >= the cREVTable["maxColumnCount"] of lObject then
     lock screen
     repeat the cREVTable["currentxcell"] of lObject - 1
       revMoveCellLeft
     end repeat
     revMoveCellDown
     unlock screen
     exit revMoveCellRight
   end if
   lock screen

etc.

8. Locate the revCalculateCellLoc handler.
9. Insert the following code before the last two lines of the handler:

   if the cREVTable["maxColumnCount"] of pObject is a number then
     put min(the cREVTable["maxColumnCount"] of pObject,txcount) into  
txcount
   end if

It should look like this when you're done:

     end repeat
   end if

    if the cREVTable["maxColumnCount"] of pObject is a number then
     put min(the cREVTable["maxColumnCount"] of pObject,txcount) into  
txcount
   end if
   set the cREVTable["currentxcell"] of pObject to txcount
   set the cREVTable["currentycell"] of pObject to tycount
end revCalculateCellLoc

10. Save and close the script and you're ready to try it out.
11. Drag a table object onto a card. It should behave  
indistinguishably from other tables.
12. If you haven't already, check the Revolution UI Elements in Lists  
menu item.
13. Open the custom properties panel for the table.
14. Select cREVTable on the menu set dropdown.
15. Click the New Custom Property button.
16. Name the custom property "maxColumnCount"
17. Set the new custom property to whatever number of columns you like.
18. Close the properties dialog, and you're set.

You should notice two difference in the table. First, if you tab or  
arrow key to the right, when you reach the specified number of  
columns, the entry field will wrap back to the left, one row lower.  
Second, if you click anywhere on the table to the right of its  
maximum column, you should see the entry field appear over the  
rightmost valid entry.

Note that these effects only take place if you set the maxColumnCount  
property in the cRevTable property set. If it is empty, nothing happens.

To make your changes permanent, save the revLibrary stack. This in  
the message box will do the trick:

   save stack "revLibrary"

That's it! You'll have to make the changes again after upgrading to a  
new version of the environment.

regards,

Geoff



More information about the use-livecode mailing list