- Home /
problem with keyboard focus on box
Hello there! my problem is quite simple, im displaying a box on screen, which has a GUIStyle and i put in 2 textures, one for the "normal" stance, and one for the "focus" stance. When i press the action button (say, Z ) i give focus to the box, and i expect it to change the color of the box from the normal stance to the image on the focus stance, but nothing happens. I wrote a debug line to show if its properly giving focus to the box and indeed it is, here is the code:
public GUIStyle aStyle
void OnGUI(){
GUI.SetNextControlName("hello");
GUI.Box(new Rect(500,250,500,100),"asd",aStyle);
if(Event.current.Equals(Event.KeyboardEvent("z")))
{
GUI.FocusControl("hello");
print(GUI.GetNameOfFocusedControl());
}
}
Im kinda confused about why isn't showing properly , i searched and tested alot of things, and got nothing. Thanks your reply!
PS: now that im here, i was wondering if is there a way to use the keys from the InputManager to use in the Event.KeyboardEvent() since im not very confortable using the actual key instead of the ones in the input manager. Thanks
Your answer

Follow this Question
Related Questions
TextField not getting focus on iOS 1 Answer
How Can I Switch Focus Between 3D Text Buttons By Using The Keyboard? 0 Answers
Unity runs in background but loses keyboard input 1 Answer
How to click a button directly while a dropdown is opened/shown? 0 Answers
Keep keyboard open when lost focus by clicking background canvas - TextMeshPro Input Field 1 Answer