- Home /
Problems with focus input and detect key.
I have an input line, for a chat. It works from this idea:
The scrollbar is has:
 GUI.SetNextControlName("Defocus");
The input line has:
 GUI.SetNextControlName("Defocus");
In function onGUI()
     if (Input.GetKeyDown (KeyCode.Return))
     {
         GUI.FocusControl("Focus");
     }
If you hit enter, it will focus the input and, later in the input thing, theres a way to throw off the focus after typing in a string. But, I wanted something like the above in the onGUI() that says if input is keycode escape, then defocus. But this doesn't work. It seems it won't register ANY key press in ongui while i am active in an input field?
+1. I'm having the same trouble and I don't understand why ...
Ok I found it :)
http://answers.unity3d.com/questions/149483/textfield-eats-all-keys-as-of-340.html
If you use Input.eat$$anonymous$$eyPressOnTextFieldFocus = false;, it works for me (I needed the escape button to work to unfocus tu textfield ...)
But the method is deprecated, so if someone knows a better way ...
Your answer
 
 
             Follow this Question
Related Questions
String as a input 2 Answers
Only KeyPress once? 1 Answer
Differnce between KeyCode.Mouse0 and GetMouseButton(0) 0 Answers
Check if pressed key exists inside an array of KeyCodes 2 Answers
Simple Quick Question 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                