Apple Newton Utilities Uživatelská příručka Strana 231

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 942
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 230
CHAPTER 6
Pickers, Pop-up Views, and Overviews
Overview Protos 6-31
Validation and Editing in protoListPicker 6
The built-in validation mechanism is not designed to deal with nested soup
information. In general, you gain more exibility by not using a
validationFrame in your pickerDef, even if you have no nested entries.
Instead, you can provide your own validation mechanism and editors:
dene a Validate method in your picker denition
dene an OpenEditor method in your picker denition
draw a layout for each editor you require
Here is how your
Validate method should work. The following example
assumes that pickerDef.ValidateName and pickerDef.ValidatePager have
been implemented:
pickerDef.Validate := func(nameRef, pathArray)
begin
// keep track of any paths that fail
local failedPaths := [];
for each index, path in pathArray do
begin
if path = 'name then
begin
// check if name validation fails
if NOT :ValidateName(nameRef) then
// if so, add it to array of failures
AddArraySlot(failedPaths, path);
end;
else begin
if NOT :ValidatePager(nameRef) then
AddArraySlot(failedPaths, path);
end;
end;
// return failed paths or empty array
failedPaths;
end;
Here is how your OpenEditor method should work:
pickerDef.OpenEditor := func(tapInfo, context, why)
begin
local valid = :Validate(tapInfo.nameRef,
tapInfo.editPaths) ;
if (Length(valid) > 0) then
// if not valid, open the editor
Zobrazit stránku 230
1 2 ... 226 227 228 229 230 231 232 233 234 235 236 ... 941 942

Komentáře k této Příručce

Žádné komentáře