
CHAPTER 10
Recognition: Advanced Topics
10-38 Using Advanced Topics in Recognition
You may also need to know the boundaries of the word in the text slot when
working with certain
protoCharEdit methods and functions. The
protoCharEdit view’s wordLeft and wordRight slots provide indexes into
the
text string that you can use to determine the boundaries of a substring suitable
for external display or for use as an argument to these routines. The
wordLeft
slot contains the index of the first externally-displayed character in the
text slot.
The
wordRight slot contains the index of the position immediately following the
last externally-displayed character in the
text slot. For example, when the text
slot holds the
"one "string, 1 is the value of the wordLeft slot and 4 is the value
of the
wordRight slot. The dispLeft slot contains the index of the first
character in the
text slot that is displayed—this character occupies the leftmost
position in the comb view. The
dispLeft slot normally has the value 0, but after
scrolling it may have values greater than 0. The
dispIndent slot is the offset
from the leftmost edge of the view to the leftmost edge of the first character displayed.
For more information, see “protoCharEdit Functions and Methods” (page 8-47) in
Newton Programmer’s Reference.
Restricting Characters Returned by protoCharEdit Views 10
This section provides code examples illustrating the use of templates to restrict the
set of characters that may appear in a comb view. Note that templates post-process
the characters returned by the recognition system before the view displays them,
rather than limiting the set of characters that the view can recognize.
The templates defined by the following code fragments are intended to serve as
examples only. The system provides templates that handle formatting conventions
for dates, times, phone numbers, and numeric values properly according to the
user’s locale. For complete descriptions of these templates, see “System-Supplied
protoCharEdit Templates” (page 8-46) in Newton Programmer’s Reference.
The following code example defines a template for a date field:
digits := "0123456789";// filters[0]
digits1 := "01"; // filters[1]
digits3 := "0123"; // filters[2]
dateTemplate := {
string:" / / ",// slashes locked by "_" in format
format:"10_20_00",// indexes into filters array
filters:[digits, digits1, digits3],
};
This example template is used in a protoCharEdit view that specifies a value of
8 or more for its maxChars slot; hence, the eight-character strings in the format
and
string slots.
Comentários a estes Manuais