Copyright © 1993-94 Apple Computer, Inc. All rights reserved. Maurice Sharp NTK 1.0. So here is a protoTable example for your enjoyment. This one will scroll up and down (though see TODO) and update a static text with the currently selected item in the table. Before you read the explanation below, make sure you know about protoApp, protoStaticText and the Allow Access From (Declare) mechanism. You should also read the docs on protoTable and setting up the table definition (though you can also look at the viewSetupFormScript of the protoTable). Scrolling --------- This is mostly done for you. What you have to do is add a viewScrollUpScript and viewScrollDownScript to your base application that just calls the same script in the protoTable. See those scripts in the protoApp. I also use the scroll scripts to do local scrolling. In other words,the arrow buttons to the side of the table simply call the viewScrollUp/DownScript of the table. Neat huh? WARNING: Due to the way scrolling is implemented by the protoTable, it is possible to 'loose' the last item in the list. In reality, the last item is not lost, it is there but can not be shown due to rounding error. The problem is in the viewScrollDownScript, however you can replace it with this one (both this function and the default one assume that tabHeights is an integer and NOT an array): func() begin local biggestTop; local temp := ((viewBounds.bottom - viewBounds.top) / def.tabHeights); temp := if (temp - Floor(temp)) < 0.5 then Floor(temp) else Floor(temp) + 1 ; biggestTop := Max(0, def.tabDown - temp) ; if vOrg < biggestTop then begin vOrg := vOrg + scrollAmount; if vOrg > biggestTop then vOrg := biggestTop ; tabbase:RedoChildren(); :updateSelection(); end; end NOTE: The default scripts provided by the protoTable prototype assume that the protoTable is Top Left parent releative justified. If you use some other form of justification, one or both of the default scrolling functions will break. You will have to write your own wrapper function that figures out if you should call the protoTable scrolling functions. Updating With New Selection --------------------------- This one is a bit skankier... protoTable has an optional slot called currentSelection. This should initially be nil, and will be set to the item in the tabValues array that is currently selected in the table. It is updated each time a selection is made. In order to update the static text item whenever a selection is made, I specialize the selectThisCell message. NOTE: I specialize it (i.e., I do an inherited:selectThisCell call). If you fail to do this BAD things will happen. So look at the selectThisCell message in the protoTable. Also notice the currentSelection slot with a nil value.