background image
C H A P T E R 5
Stationery
5-10
Using Stationery
// Generic entry definition:
DefConst('kEntryTemplate, {
class: kDataSymbol,
viewStationery: kDataSymbol,// vestigial; for Notes
// compatibility
title: nil,
timeStamp: nil,
height: 176,
// For page and paper roll-type apps
// this should be the same as height
// slot in dataDef and viewDefHeight
// slot in viewDef (if present)
});
// This facilitates writing viewDefs that can be reused
kEntryTemplate.(kDataSymbol) := {
who: nil,
howMuch: 0,
dueDate: nil,
};
MakeNewEntry: func()
begin
local theNewEntry := DeepClone(kEntryTemplate);
theNewEntry.title := ShortDate(time());
theNewEntry.timeStamp := time();
theNewEntry.(kDataSymbol).dueDate := time();
theNewEntry;
end;
The
StringExtract
method is called when an overview is generated and is
expected to return a one or two-line description of the data. Here is an example of a
StringExtract
implementation:
StringExtract: func(item,numLines)
begin
if numLines = 1 then
return item.title
else
return item.title&&item.(kDataSymbol).who;
end;
The
TextScript
method is called by the routing interface to get a text version of
an entire entry. It differs from
StringExtract
in that it returns the text of the
item, rather than a description.
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна