I’m sure I’m not the first person who wants to use an Insert Text action and then be able to continue typing from a point within the inserted text. But I haven’t been able to find out how to do it from a quick search-and-skim of the documentation and this forum. Can someone set me on the right track?
You could select a zero-length portion of the draft.
I don’t understand. A concrete example of what I want: a parentheses button in the action bar which will insert the ‘(’ and ‘)’ characters and place the cursor between them, so I can avoid having to repeatedly switch keyboard registers.
Pretty straightforward with a bit of JavaScript. Here’s a function you can drop into a script step and re-use. It takes two parameters. The text you want to insert before the cursor and the text you want to insert after the cursor.
function insertAndPosition(p_strPrefix, p_strSuffix)
{
editor.setSelectedText(p_strPrefix + p_strSuffix);
editor.setSelectedRange(editor.getSelectedRange()[0] + p_strPrefix.length, 0);
}
Then you can just call it like this for your example.
insertAndPosition("(",")");
Hope that helps.
Just the ticket, thanks! Learning Javascript is on my to-do list… but it’s a rather long list!
I thought the question was how to position an insertion cursor. Selecting text where the start and end of the selection are the same is one way of doing it - in many environments.