Copy link to clipboard
Copied
Hey everyone,
Does anyone know how to get the X and Y coordinates of a character in a string based on index? I find it odd that I can get the exact letter and index by clicking a character in a text field, but I haven't found anything in code that can get those coordinates without a user click. Seems like they would have to know the x,y of the individual indexs to be able to tell you what letter you're clicking based on your own mouse coordinates.
Copy link to clipboard
Copied
if you're using a tlftextfield, you can use the getCharAtPoint() method.
Copy link to clipboard
Copied
That's what I've been using to get characters and indexes. I'm trying to get the x and y location of a character by simply feeding it the index of the string.
Copy link to clipboard
Copied
iterate through your textfield indices using that method to find the corresponding x,y
Copy link to clipboard
Copied
Just try this...
Once you get proper character's index, use the following code,
myTxtFld.getCharBoundaries(index); // this will return a rectangle.
myTxtFld.getCharBoundaries(index).x; // ===========> will provide x coordinate and
myTxtFld.getCharBoundaries(index).y; // ===========> will provide y coordinate.
Good luck !!
Copy link to clipboard
Copied
Does anyone have any ideas how this can be done with createjs?
Need to overlay specific strings within a textfield.
Cheers.