C H A P T E R 8
Text and Ink Input and Display
a view descended from
flag set in
The Caret Pop-up Menu
Normally, when the user taps the insertion caret, the system-provided Punctuation
pop-up Menu opens. However, you can override this with a pop-up menu of your
When the user taps the insertion caret, the system starts searching for a slot named
. The search begins in the view owning the caret, and follows both
the proto and parent inheritance paths. The default Punctuation pop-up is stored in
the root view.
slot must hold a frame containing two slots. The first slot,
, defines a list of pop-up items suitable for passing to
. The second
slot must contain a
. If not, control passes to the punctuation
pop-up, which has its own version of the
. This routine then
inserts a string, corresponding to the selected character at the caret, by using the
Handling Input Events
You sometimes need to respond to input events that occur in text views. This
section describes how to test for a selection hit and respond to keystrokes and
Testing for a Selection Hit
After the user taps the screen, you can determine if the point "hits" a specific
character or word in a paragraph view.
method returns the offset within the paragraph
that is closest to the point (x, y). This method is described in "PointToCharOffset"
(page 7-51) in Newton Programmer's Reference.
method returns a frame that indicates the position of
the word within the paragraph that is closest to the point (x, y). This method is
described in "PointToWord" (page 7-52) in Newton Programmer's Reference.
Both of these functions return
if the view is not a paragraph
view. Also, the point you are testing must correspond to a visible
position within the paragraph view; you cannot hit-test on
off-screen portions of a view.