Mouse click selecting word in GUI

I'm attempting to make specific words in a GUI.Window click activated (text message appears in window, user clicks on one specific word, and an action happens). I've recently found the GUISettings.doubleClickSelectsWord option, but no reference to exactly how it works or how to use it.

How would I use this to enable click activation of text in the GUI.Window. Then, how do I reference in the script which word was clicked so I can make a specific action happen?

more ▼

asked Feb 20, 2010 at 05:04 PM

avatar image

Jeff Lowe
32 4 5 5

(comments are locked)
10|3000 characters needed characters left

2 answers: sort oldest

I haven't dealt with GUISettings.doubleClickSelectsWord yet, but I suspect that it won't do what you're after. It's used for text fields where the user enters text. Double-clicking on the word would highlight this word just like in a text editor.

I'd probably go for GUI.button and use the words that you need as texture. If you then click on the word, the button registers a click and you can trigger stuff. That would fairly resemble what you're after. Not perfect, but probably more suitable then a text field.

more ▼

answered Feb 21, 2010 at 03:38 AM

avatar image

5.3k 29 42 82

If double-clicking word in the text field selects the text word, how do you access that word in the script, or is there a way? I would love to hear form someone that has used this command too.

Feb 22, 2010 at 10:29 PM Jeff Lowe

The text field is still intended for the user to manipulate the string. I doubt it's useful for displaying a string and having the user click on something. From the documentation you can only access the complete string of the text field, not the "highlighted" substring. If somebody has experience with using a text field for such purpose, I'd be keen to hear that as well.

Feb 22, 2010 at 10:54 PM Sebas
(comments are locked)
10|3000 characters needed characters left

unity's GUI is a litle different from what you see in other GUI packages. you can get the click event of a button easily or you can use toolbars or selection grids but if you need to get the selected word in a textfield it's not easy. you should use GUIUtility and GUI classes with Event class to work with GUIs in advanced. there are two problems. 1 the documentation of GUIUtility is not complete by no means and getting the info about the text in a textfield needs much more effort. you should opentype library and know the font well to understand the size of the texture for some word and ... don't try it :)

more ▼

answered Jun 13, 2010 at 11:52 AM

avatar image

10.5k 78 127 171

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Feb 20, 2010 at 05:04 PM

Seen: 3773 times

Last Updated: Feb 20, 2010 at 05:04 PM