Text items support the notion of an index for identifying particular positions within the item.
In a similar fashion, line and polygon items support index for identifying, inserting and deleting subsets of their coordinates.
Indices are used for commands such as inserting or deleting a range of characters or coordinates, and setting the insertion cursor position. An index may be specified in any of a number of ways, and different types of items may support different forms for specifying indices.
Text items support the following forms for an index; if you define new types of text-like items, it would be advisable to support as many of these forms as practical. Note that it is possible to refer to the character just after the last one in the text item; this is necessary for such tasks as inserting new text at the end of the item.
Lines and Polygons don't support the insertion cursor and the selection.
Their indixes are supposed to be even always, because coordinates always appear in pairs.
- number
- A decimal number giving the position of the desired character within the text item. 0 refers to the first character, 1 to the next character, and so on. If indexes are odd for lines and polygons, they will be automatically decremented by one. A number less than 0 is treated as if it were zero, and a number greater than the length of the text item is treated as if it were equal to the length of the text item. For polygons, numbers less than 0 or greater then the length of the coordinate list will be adjusted by adding or substracting the length until the result is between zero and the length, inclusive.
- end
- Refers to the character or coordinate just after the last one in the item (same as the number of characters or coordinates in the item).
- insert
- Refers to the character just before which the insertion cursor is drawn in this item. Not valid for lines and polygons.
- sel.first
- Refers to the first selected character in the item. If the selection isn't in this item then this form is illegal.
- sel.last
- Refers to the last selected character in the item. If the selection isn't in this item then this form is illegal.
- @x,y
- Refers to the character or coordinate at the point given by x and y, where x and y are specified in the coordinate system of the canvas. If x and y lie outside the coordinates covered by the text item, then they refer to the first or last character in the line that is closest to the given point.
© Author
| Home
| Sitemap
|