View Single Post
02-07-13, 03:34 AM   #7
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Socratesx View Post
I speak about translate "just single word"
Right, but where do you want the word to come from? If you want it to come from a chat message, your only options are (a) type the word into a box yourself, or (b) copy the whole chat message and translate each word in the message separately.

There isn't a way to programatically determine which word is under the mouse cursor. You can tell which font string object is under the mouse cursor, and get the whole text of the font string. You could also try to guess which word is under the cursor -- if the font string is 100px wide, and the mouse is 25px from the left, try to guess which word is there by going through each letter/space/etc in the font string's text and guessing its width based on a fixed table (eg. "i" takes up 3px of screen space, "m" takes up 9 px, etc) -- but since the width of letters depends on both the text size and the properties of the font face you're using, it's tricky and unreliable.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote