View Single Post
Unread 02-07-13, 03:34 AM   #7
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,751
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.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote