Author Topic: [Solved] UIInput OnSubmit loses focus  (Read 2754 times)

Whippets

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
[Solved] UIInput OnSubmit loses focus
« 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)?
« Last Edit: July 26, 2013, 10:12:15 AM by Whippets »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput OnSubmit loses focus
« Reply #1 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.

Whippets

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: UIInput OnSubmit loses focus
« Reply #2 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.