Author Topic: UIInput text after losing focus  (Read 7548 times)

StridingDragon

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 53
    • View Profile
UIInput text after losing focus
« on: February 08, 2013, 02:09:18 AM »
Sadly UIInput does not generate an OnSubmit() event when it loses focus because the user clicked on a different button, even though it is technically equivalent to accepting the input. Is there some other event that I could use to capture this happening, so that the contents of the text field can be properly checked, manipulated and copied to wherever they need to go?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput text after losing focus
« Reply #1 on: February 08, 2013, 07:30:17 AM »
Leaving the field does not mean submitting it. Hitting Enter is submitting it. If you want it to submit on lost focus, write a script that has OnSelect (bool selected) in it, and react to it.

StridingDragon

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 53
    • View Profile
Re: UIInput text after losing focus
« Reply #2 on: February 08, 2013, 10:52:50 AM »
I thought I tried that and never once received an OnSelect event, but I'll try again. Thanks for the tip.

StridingDragon

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 53
    • View Profile
Re: UIInput text after losing focus
« Reply #3 on: February 08, 2013, 08:54:29 PM »
Thanks a bunch, Aren. I got it to work with OnSelect, just as you suggested.

StridingDragon

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 53
    • View Profile
Re: UIInput text after losing focus
« Reply #4 on: February 11, 2013, 09:13:14 PM »
By the way, I just wanted to let you know that I disagree with your assessment that leaving a field is not the same as submitting. In my view - and I am sure in the view of most people, it most definitely is the same thing.

Phoenix2518

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 4
    • View Profile
Re: UIInput text after losing focus
« Reply #5 on: December 07, 2014, 12:39:39 PM »
Almost two years later, I encountered the same issue. I have to agree with StridingDragon - losing focus should be considered submitting the text. After all, that's how every text box in the Unity editor works, for validation purposes.