Skip to main content
rombanks
Inspiring
November 13, 2014
Answered

ES for FM10: Adding text at insertion point

Hello fellows,

What's the code for current insertion point (where the cursor is currently placed?)

I saw code for adding text in the beginning/end of pgf but not at the current insertion point.

Thank you in advance!

This topic is closed to new replies. Start a new post to keep the conversation going.
frameexpert
frameexpertCorrect answer
Community Expert
November 13, 2014

Try using textLoc instead of TextLoc for your variable. TextLoc with this spelling is a reserved word.

www.frameexpert.com

22 replies

frameexpert
Community Expert
Community Expert
November 13, 2014

Assuming doc is the active document, this will give you the current text selection:

var textRange = doc.TextSelection;

To get the insertion point, use either:

var textLoc = doc.TextSelection.beg;

or

var textLoc = doc.TextSelection.end;

-Rick

Translate
www.frameexpert.com
rombanks
rombanksAuthor
Inspiring
November 13, 2014

Hi Rick,

Thank you for your response and suggestion!

The following code does not do anything while the cursor is in a paragraph,. Am I missing something?

var doc = app.ActiveDoc;

var Tsel = doc.TextSelection;

var TextLoc = Tsel.beg;

doc.AddText (TextLoc, "Test ");

Thank you!

Translate
frameexpert
Community Expert
frameexpertCommunity ExpertCorrect answer
Community Expert
November 13, 2014

Try using textLoc instead of TextLoc for your variable. TextLoc with this spelling is a reserved word.

Translate
www.frameexpert.com