Is there a way to check to see if a GUI object (window, text field, etc) has focus? I don’t need to know what item specifically, I just need to know if any GUI object has focus.
I’m looking for a way to do this so that I can determine whether I should be catching Input keypresses for commands or for typing in a text field.
I’ve tried a generic test with GUIUtility.keyboardControl but once a field gets focus, I can’t get it to focus on anything but other windows, which means that my script isn’t processing any commands.
void Update () {
if (GUIUtility.keyboardControl == 0) {
// process keystrokes as commands
}
}
I’d like to avoid this if at all possible as it would be better if the Input simply ignored keystrokes until focus moved away from a text field or other GUI element. I also can’t get it to focus on anything but text fields at the moment either, but that’s another issue…
Any suggestions?