Get current GUI control with focus?

How do I get the name of the GUI control that currently has focus?

I’ve searched the forums docs but have found no way of doing so.

Am I missing something obvious ( hopefully )?

GUIUtility.keyboardControl -Use this to figure out which control has the caret/keyboard focus (I’m not confident this works 100% on windows though)
GUIUtility.hotControl - use this to see which control is “active” i.e. has mousedown. It gets reset to 0 on mouseup.

Also - there’s a GUI section in this forum. Please post GUI questions there.

Cheers
Shaun

GUIUtility.keyboardControl returns an integer that appears to be an internal ID. I can’t find a straightforward way of getting this internal ID for a control. I would like to get the name of the control, since it is the only means we have to assign an ID.

GUI.SetNextControlName and FocusControl are the only ways I know of accessing controls by name.
I haven’t tried this, but GUIUtility.GetControlID seems like it gets the ID of the next GUI control. Good luck :slight_smile:

I’ve searched the forums docs but have found no way of doing so