background image
C H A P T E R 7
Controls and Other Protos
Button and Box Protos
Implementing a Simple Button
To provide a simple button in your application, pick a button proto to use, set the
appropriate slots in the button object, and (in most cases) define one or more
scripts for the button.
The following is an example of a template that includes
aButton := {...
_proto: protoTextButton,
viewFont: ROM_fontSystem12Bold,
text: "My Button",
ButtonClickScript: func()
// a handy way to fit a button around a string
ViewSetupFormScript: func()
viewbounds := RelBounds(10, 60,
StdButtonWidth(self.text), 13);
The above example creates the following button on the Newton screen:
When the user taps this button in the Inspector, "ouch" is printed to the Inspector.
You implement a picture button with a similar template, as shown in the
following example:
pictButton := {...
_proto: protoPictureButton,
icon: namesBitmap,
viewBounds: SetBounds( 2, 8, 34, 40 ),
ButtonClickScript: func()
For more information on implementing specific button and box protos, see "Button
and Box Protos" (page 7-6) in Newton Programmer's Reference.
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна