background image
C H A P T E R 7
Controls and Other Protos
Time Protos
7-15
Figure 7-22
A
protoNewSetClock
view
The
protoSetClock
time proto also displays an analog clock with which the
user can set a time value. Although this proto is still available for use, it has
been updated to the
protoNewSetClock
, which you should use instead.
The
protoAMPMCluster
time proto displays
A
.
M
. and
P
.
M
. radio buttons in a
protoNewSetClock
view. For more information about the slots and methods
for this proto, see "protoAMPMCluster" (page 6-44) in Newton Programmer's
Reference
. Figure 7-23 shows an example of a
protoAMPMCluster
view.
Figure 7-23
A
protoAMPMCluster
view
Implementing a Simple Time Setter
7
To implement a time setter, define your template with the proto that you want
to use, specify the initial time value to show in the clock, and define the
TimeChanged
method. You might also need to define additional slots or messages,
as described in "Time Protos" (page 6-38) in Newton Programmer's Reference.
The following example is a template that uses
protoDigitalClock
to allow the
user to specify a time:
clock := {...
_proto: protoDigitalClock,
time: 0,
TimeChanged: func()
begin
// add your code to respond to time change
print(time);
end,
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна