viewSetupFormScript()

Setting Values in viewSetupFormScript

Here is an example of setting the text of a view at run-time, rather than from within NTK. This is the viewSetupFormScript for a static text which displays the Newton owner's name:

func()
begin
   inherited:?viewSetupFormScript();
   local textWidth;
   self.text := GetUserConfig('name);
   textWidth := StrFontWidth(text, viewFont);
   self.viewBounds := {
      _proto: viewBounds,
      right: viewBounds.left + textWidth,
   };
end

Note:GetUserConfig returns a specified slot from the user configuration frame. StrFontWidth returns the width (in pixels) of the specified text using the specified font. See Newton Programmer's Guide for more details.


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

Last modified: 1 DEC 1996