background image
C H A P T E R 7
Controls and Other Protos
Scroller Protos
Scrolling in the Dates Application
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
for that time frame. This tells the scroller to
blacken a scroll arrow when the data time frame is not displayed in the
providing additional visual feedback to the user.
scrollRect: SetBounds(0, 0, 0, 24)
// 24 hours per day
SetBounds(0, 0, 0, 7)
// show 7 at a time
SetBounds(0, 0, 0, 10)
// meeting from 9-10
Scrolling In a Graphics Application
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
SetBounds( 0, 0, 50, 50)
// there's something at location (100,100)
SetBounds(100, 100, 110, 110)
Scroll Amounts
Whenever the
method is called, the scroller proto
increments the
by 1. For example, in the Dates application example,
each time the user taps an arrow, the
is moved up or down by 1 hour.
In the graphics application example, each time the user taps an arrow, the
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
slot, which is an array of three
values. The default value of this slot is:
[1, 1, 1]
The first value in the
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 » при воспроизведении материала сайта ссылка обязательна