Find out when enter key is pressed in IntField

I’m writing a custom inspector. I am using the EditorGUILayout.IntField.

Now the problem is the value is changed just by typing in the box, i want it to be triggered when i press enter in that box or when it looses focus.

How do I do that? I can’t find anything in the documentation…

You should be able to use that to detect when a control gains/loses focus.

To get it to ONLY update the variable when it loses focus though, I honestly can’t think of a solution aside from having a temp variable pair to be honest. Basically, you would need 2 variables per “variable” - one that gets updated live and one that only gets updated on focus change… You would also need to store the control ID of the intfield, as well as cache the the result of keyboardControl so you can monitor when it change sand push the update to your “real” variable.

It’s a pretty convoluted solution though; out of curiosity, what is your main goal here? There may be an easy solution than trying to hack around the way IntField works.

Yes the reason is I wanted to have fields that look like the standard ones when not creating a custom editor. But should I use a different kind of field then?