Author Topic: UIInput Events  (Read 4230 times)

joeleaver

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
UIInput Events
« on: November 05, 2013, 09:03:55 AM »
Loving the changes since 3.0.3!

It'd be great if UIInput had an OnChange event that fired if the value changed for any reason. OnInput is close, but doesn't fire if the value is changed programmatically.

Or should I be thinking it a different way?

Thanks!

MaRTiDoRe

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UIInput Events
« Reply #1 on: November 05, 2013, 09:25:37 AM »
I need something similar to this. I want to check things everytime the inpu text changes, not only when pressing Enter (OnSubmit).

Right now I'm doing it by modifying the UIInput script itself, but it would be great to have a more advanced OnChange event.
« Last Edit: November 05, 2013, 09:55:09 AM by MaRTiDoRe »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput Events
« Reply #2 on: November 05, 2013, 12:21:42 PM »
UIInput.onValidate is called every time the text changes, but it won't fire if the UIInput.value is set programmatically -- just from keyboard input.

joeleaver

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: UIInput Events
« Reply #3 on: November 05, 2013, 11:03:49 PM »
My use case is as the filename input for a file browser widget. The value could change when a user clicks a file listing, or they could type, so you can see why an onChange event might be useful. Not too hard to edit UIInput myself to add it, but it seems like a natural fit for an input text field.

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput Events
« Reply #4 on: November 06, 2013, 08:10:44 AM »
Fair point. You will see UIInput.onChange in the next update.

joeleaver

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: UIInput Events
« Reply #5 on: November 06, 2013, 11:51:25 AM »
Thanks! You're the best. Awesome support on the forums was the #1 reason I purchased NGUI.

Ernest

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 40
    • View Profile
Re: UIInput Events
« Reply #6 on: January 10, 2014, 10:42:04 AM »
I suppose you forgot to update the input inspector on this one... :)

dbuck

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: UIInput Events
« Reply #7 on: January 10, 2014, 03:53:14 PM »
Is there a good way to get an OnDeselect event? Case being the user starts to type, but does not hit enter to submit, I'd like a way to be able to restore the initial text.

Should I just subclass the UIInput and override the SelectionStart and SelectionEnd events to do my editing hooks?

Just going to leave this here for anyone else who's looking for something similar, but you can use the OnSelect(bool) event from UICamera on a script adjacent to the uiInput... yay.