background image
C H A P T E R 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 flexibility 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:
define a
Validate
method in your picker definition
define an
OpenEditor
method in your picker definition
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
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна