background image
C H A P T E R 1 0
Recognition: Advanced Topics
Using Advanced Topics in Recognition
10-11
Sketch ink, like shapes, is displayed only in views based on the
clEditView
class. As a rule of thumb, consider sketch ink and ink text to be mutually exclusive
when configuring recognition in views; for best results, configure your input view
to recognize only one of these two data types.
Views based on the
clEditView
class handle sketch ink and ink text automatically.
For other views, the system invokes the view's
ViewInkWordScript
or
ViewRawInkScript
method when ink arrives. For more details, see the
descriptions of these methods in Newton Programmer's Reference.
The system-supplied
ROM_rcInkOrText
constant provides a ready-to-use
recConfig
frame that allows views based on the
clParagraphView
class to
contain ink text in addition to normal text. To use this
recConfig
frame to create
a view that supports ink text, you'll need to take the following steps:
Create a view template that protos from the
clParagraphView
class.
In your view template, create a
recConfig
slot that holds the
ROM_rcInkOrText
constant. For more information, see "Creating a recConfig
Frame" beginning on page 10-9.
Provide a
protoRecToggle
view that allows the user to choose text or ink
text settings; if your application provides a status bar, you need to provide the
recToggle
view as one of its children. For more information, see "Creating
the recToggle View" beginning on page 10-19.
Provide a
_recogSettings
slot at an appropriate position in the
recToggle
view's
_parent
chain. For more information see "Creating the _recogSettings
Slot" beginning on page 10-20.
Normally, the input view tries to recognize input using all currently enabled
recognizers. If no recognizers are enabled or if recognition fails for some reason--
for example, due to messy input or some sort of error--then the view system
converts the input strokes into ink. The
doInkWordRecognition
slot in the
input view's
recConfig
frame specifies the kind of ink that the system creates
from the input strokes.
When the
doInkWordRecognition
slot holds a non-
nil
value, the system
returns ink text; when this slot holds the
nil
value, the system returns sketch ink.
This slot is described fully in "protoRecConfig" (page 8-36) in Newton
Programmer's Reference
. Table 10-1 on page 10-12 summarizes the kinds of data
returned by the recognition system when recognition fails in an edit view or
paragraph view that is controlled by a
recToggle
view.
Note that when the input view is set to recognize shapes, the smoothed and cleaned
up ink that is returned may be ink text but is more likely to be a curve shape. Aside
from the failure of shape recognition, the only time raw ink is returned to the view
is when its associated
recToggle
is set to "Sketches".
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна