Replace
protoTXView:Replace(range, data, undoable)
Replaces the data inside of the specified range with the specified data. You can replace text and/or graphics with this method.
EXAMPLE
- range
- A range frame defining the text range that you want to change. See "The Range Frame".
- data
- A frame describing the new data. This can be a graphics specification frame, as described in "The Graphics Specification Frame". Or data can be a frame with the following slots:
text
If this slot isnil
, style runs are replaced, but the text remains the same. If non-nil
, this is the new text string.
styles
If this slot isnil
, the new text uses the style attributes at the start of the range. If non-nil
, this is an array with two entries for each style run in the range. The first entry specifies the number of characters, and the second is either a font specification frame or a graphics specification frame. The run length is always 1 for graphics specification objects. For a description of the font specification frame, see the section "Font Frame" (8-18) in Newton Programmer's Guide. See "The Graphics Specification Frame" for a description of the graphics specification frame.
- undoable
- If non-
nil
, the operation is undoable.
- return value
- An error code, or
nil
if the operation worked.
The following call to the *
Replace
method changes the first ten characters to the word "any" using the system font, bold face, point size 9:
The following call to the *myTxView:Replace( {first:0, last:10},
{text:"any", styles: [3, tsSystem+tsSize(10)+tsBold]} );
Replace
method changes the first ten characters of the range to a rounded rectangle:
myShape:= makeroundrect(0, 0, 50, 50, 16);
myTxView:Replace({first:0, last:10}, {class: 'graphics, shape: myShape})
Main | Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help