background image
C H A P T E R 6
Pickers, Pop-up Views, and Overviews
6-30
Overview Protos
See "Column Specifications" (page 5-3) in Newton Programmer's Reference for
details of the slots.
Having a Single Selection in a List Picker
6
The key to getting single selection is that single selection is part of the picker
definition and not an option of
protoListPicker
. That means the particular
class of
nameRef
you use must include single selection. In general, this requires
creating your own subclass of the particular name reference class.
The basic solution is to create a data definition that is a subclass of the particular
class your
protoListPicker
variant will view. That data definition will include
the
singleSelect
slot. As an example, suppose you want to use a
protoPeoplePopup
that just picks individual people. You could use the
following code to bring up a
protoPeoplePopup
that allows selecting only one
individual at a time:
// register the modified data definition
RegDataDef('|nameref.people.single:SIG|,
{_proto: GetDataDefs('|nameRef.people|), singleSelect:
true});
// then pop the thing
protoPeoplePopup:New('|nameref.people.single:SIG|,[],self,[
]);
// sometime later
UnRegDataDef('|nameref.people.single:SIG|);
For other types of
protoListPickers
and classes, create the appropriate
subclass. For example, a transport that uses
protoAddressPicker
for e-mail
messages might create a subclass of
'|nameRef.email|
and put that subclass
symbol in the class slot of the
protoAddressPicker
.
Since many applications are likely to do this, you may cut down on code in your
installScript
and
removeScript
by registering your
dataDef
only for the
duration of the picker. That would mean registering the class just before you pop
the picker and unregistering after the picker has closed. You can use the
pickActionScript
and
pickCanceledScript
methods to be notified when
to unregister the
dataDef
.
Having Preselected Items in a List Picker
6
If you want to have items that are initially selected in a list picker, use the
viewSetupDoneScript
to set up the selected array, rather than setting up
the selected array in your
viewSetupFormScript
or
viewSetupChildrenScript
, then send the
Update
message to
protoListPicker
to tell it to update the display.
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна