View System and Messages

Changing View System Attributes

You can make changes to slots that affect the appearance of a view (for instance, viewBounds or viewJustify) in the viewSetupFormScript. When the viewCObject is created, it reads the values of these slots from the view and initializes itself appropriately. After the viewCObject has been created, you can't just directly change slots in the view, because the viewCObject won't know to reread the slots. Instead, you must somehow notify the viewCObject when you change a slot.

The way to do this is with the SetValue function. Call it with:

SetValue(view, 'slot, newValue)
This sets the slotSymbol slot of view to newValue and then notifies the view that it has changed. The viewCObject, once it has been notified that a change has taken place, incorporates the new slot value. If, for instance, the viewBounds slot changes, the viewCObject will resize the view.

In summary, then, after the viewSetupFormScript of a view has executed, don't directly change slot values used by the view system with:

view.slot := newValue
Instead, use:

SetValue(view, 'slot, newValue);

An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.

Last modified: 1 DEC 1996