background image
C H A P T E R 7
Controls and Other Protos
Scroller Protos
7-5
Scrolling in the Dates Application
7
Scrolling in the Dates application allows the user to see the 24 hours in a day, 7
hours at a time. When there is only interesting data in a certain range of the day,
the application sets the
dataRect
for that time frame. This tells the scroller to
blacken a scroll arrow when the data time frame is not displayed in the
viewRect
,
providing additional visual feedback to the user.
scrollRect: SetBounds(0, 0, 0, 24)
// 24 hours per day
viewRect:
SetBounds(0, 0, 0, 7)
// show 7 at a time
dataRect:
SetBounds(0, 0, 0, 10)
// meeting from 9-10
Scrolling In a Graphics Application
7
A final example shows scrolling in a graphics application. This example shows a
total scrollable area of 200 pixels by 200 pixels, of which a 50 pixel by 50 pixel
area is shown at any one time. In this example, an object of interest (data) is
located at (100,100).
// total area is 200 by 200
scrollRect: SetBounds( 0, 0, 200, 200)
// show a 50 by 50 area at a time
viewRect:
SetBounds( 0, 0, 50, 50)
// there's something at location (100,100)
dataRect:
SetBounds(100, 100, 110, 110)
Scroll Amounts
7
Whenever the
ViewScroll2DScript
method is called, the scroller proto
increments the
viewRect
by 1. For example, in the Dates application example,
each time the user taps an arrow, the
viewRect
is moved up or down by 1 hour.
In the graphics application example, each time the user taps an arrow, the
viewRect
is moved up or down by 1 pixel. Since scrolling by 1 pixel at a time is too slow,
you need to be able to adjust the scrolling amount for certain applications. To do
so, you change the value of the
scrollAmounts
slot, which is an array of three
values. The default value of this slot is:
[1, 1, 1]
The first value in the
scrollAmounts
array specifies the amount to scroll for a
single tap. The second value specifies the amount to scroll when the user holds
down on the arrow (accelerated scrolling), and the third value specifies the amount
to scroll for a double tap. For a typical graphics application, you can use values like
the following:
[10, 50, 50]
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна