beautypg.com

Scrolling examples 7 – Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 264

background image

C H A P T E R 7

Controls and Other Protos

7-4

Scroller Protos

viewRect

, and

dataRect

. Each of these slots is a bounds frame with the

following form:

{left: 0, top: 0, right: 10, bottom: 10}

You usually create these bounds frame slots with the utility function

SetBounds

,

which is described in “SetBounds” (page 2-34) in Newton Programmer’s Reference.

When you use these slots, the scroller protos highlight the scrolling arrows
automatically to indicate to the user that more data can be viewed by tapping on the
highlighted arrows.

Each of the bounds frame slots serves a specific purpose in the scroller, as shown in
Table 7-1. The next section provides several examples of setting the values of these
slots for different scrolling effects.

Scrolling Examples

7

This section presents several simple examples of setting the bounds frame slots in
your scroller to allow scrolling.

Scrolling Lines of Text

7

To scroll lines of text, you set the values of the three scroller bounds frames as
required for your application. For example, if you have 20 text items in a vertical
list and you want to show 6 of the items at a time, you need to set the slot values
as follows:

scrollRect: SetBounds(0, 0, 0, 20)

// 20 possible lines

viewRect:

SetBounds(0, 0, 0, 6)

// show 6 at a time

dataRect:

SetBounds(0, 0, 0, 20)

Table 7-1

Scroller bounds frame slots

Slot name

Description

scrollRect

Specifies the scrollable area, which is the total area that the
user can see, or scroll over, with the scroller.

viewRect

Specifies the part of the scrollable area that the user can
see at any one time. This is usually smaller than the area
specified by

scrollRect

.

dataRect

Specifies the portion of the

scrollRect

that contains

data. In simple cases, this is the same as

scrollRect

.