Find Selection Cursor in TextEntry box?

Sep 04, 2013

I'm trying to set non-common characters into a Data Entry box via JS. So far, I've been able to work with the variables, which is a half-solution.

The code is this:

var player = GetPlayer();
var theTextOrig = player.GetVar("TextEntry");
var theNewTextOrig = theTextOrig + "ā";
player.SetVar("TextEntry", theNewTextOrig);

This simply concatenates what ever is in the Text Entry box with a "ū" on the end.

What I'd really like to do is add that "ā" at the cursor point in the Text Entry box however. So if you have "ch" in the box with the selection cursor at the end and click my button to add "ā", it adds it at the end. If you have the selection cursor between "c" and "h", it inserts "ā" between them, so "cāh". If you have "c" selected but not "h", and insert "ā", the result will be "āh".

See what I mean?

Is there anyway to do this in JavaScript?

3 Replies

This discussion is closed. You can start a new discussion or contact Articulate Support.