
CHAPTER 10
Recognition: Advanced Topics
Using Advanced Topics in Recognition 10-37
Manipulating Text in protoCharEdit Views 10
The default view provided by the protoCharEdit proto is an unformatted comb
view (see page 10-4). You can provide an optional template that customizes this
view’s appearance and behavior. The template itself is a frame residing in the view’s
template slot. This frame may provide the following slots and methods:
■ The template’s filter slot defines a set of permissible input values. For
example, a view for correcting phone numbers might restrict the set of
permissible characters to numerals.
■ The template’s format slot can specify the length of the comb view and the
editing characteristics of its entry fields. For example, the phone number
correction view might use a format template to restrict input to a fixed number
of characters and make certain entry fields non-editable. When the comb view
erases invalid characters it displays the animated cloud and plays the
ROM_poof
sound that normally accompanies the scrub gesture.
■ The template’s text slot supplies a string to be displayed initially when the
comb view opens. The comb view retrieves this value when its
ViewSetupFormScript is executed.
■ You can also supply optional SetupString and CleanupString functions
that manipulate the string in the
text slot.
For complete descriptions of these slots, see “Template Used by ProtoCharEdit
Views”(page 8-45) and “Application-Defined protoCharEdit Template Methods”
(page 8-52) in Newton Programmer’s Reference.
The system also provides several global functions that are useful for manipulating
protoCharEdit views and the strings they display.
To change the comb view’s text string or template dynamically, call the
UseTextAndTemplate function after setting appropriate values for the
text or template slots. Alternatively, you can use the SetNewWord or
SetNewTemplate and UseNewWord or UseNewTemplate functions to perform
the same operations; in fact, calling these functions yourself is faster than calling
the
UseTextAndTemplate function.
To get the current value of the text in the comb view, you can send the
CurrentWord message to the view. You must not use the value of the text slot
directly, because unformatted comb views may add extra spaces to the string in this
slot. To get a special version of the text that is formatted for display in a view other
than the comb view, use the
GetWordForDisplay function. If you are using a
template, this function may return the string in a more standardized format,
because it calls the template’s optional
CleanupString function before returning
the string.
Comentários a estes Manuais