I have successfully created a tcl text object and filled it with text. focus .textpath sets the focus, but pressing an arrow takes me to the end of the text.
how do I ensure the insertion point is at the beginning of the text without user intervention?
CodePudding user response:
The insertion point is the insert
mark, which defaults to having right gravity (so text inserted at the point where the mark is goes to the left of it).
To move a mark programmatically, use the mark set
method:
$txt mark set $mark $position
The $position
can be any valid text location descriptor, including 1.0
for the start of the text (it looks like a floating point number but isn't; it's $line.$char
), end
for the end, 1.end
for the end of the first line, etc.
In your case, to move the insertion position to the start, do this:
$txt mark set insert 1.0