Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Whippets on July 25, 2013, 09:30:12 AM

Title: [Solved] UIInput OnSubmit loses focus
Post by: Whippets on July 25, 2013, 09:30:12 AM
I've got a UIInput widget which works as intended, but seems to lose the focus after Return is pressed and the OnSubmit event is fired.

I get the OnSubmit event, and deal with the text, before setting the text to empty myUIInput.text = "";
At this point, the UIInput seems to lose focus, and only clicking inside it again makes it selected.

I've tried myUIInput.selected = true; but that doesn't seem to do anything. I've tried setting .selected to false then to true, but that doesn't help either.

How do I refocus the UIInput using code C# so that it's automatically ready to receive more input from the keyboard (as if I'd clicked inside it)?
Title: Re: UIInput OnSubmit loses focus
Post by: ArenMook on July 26, 2013, 04:09:58 AM
You might need to delay your selection until end of frame, or look inside UIInput and just change it there.
Title: Re: UIInput OnSubmit loses focus
Post by: Whippets on July 26, 2013, 10:11:53 AM
Yep, thanks for that, fixed it perfectly. If you wait in a coroutine for the end of the frame, then set the object as selected, the carat appears, and the object accepts keyboard input.