Skip to main content
rombanks
Inspiring
November 13, 2014
Answered

ES for FM10: Adding text at insertion point

  • November 13, 2014
  • 1 reply
  • 3318 views

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 has been closed for replies.
Correct answer frameexpert

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

1 reply

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

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!

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.

www.frameexpert.com