Author Topic: UIInput, deleting buffer?  (Read 3375 times)

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
UIInput, deleting buffer?
« on: November 28, 2012, 09:33:19 PM »
This is probably an easy one but I can't seem to figure it out.

I use UIInput to enter a string, such as "Hello". I press enter, and the string is saved to my UILabel.
However when I open UIInput again, the prompt is blank, but as soon as I type "Hello" appears again in the display box.

How do I delete this?

I've setting a blank string to both the .text of the UILabel I'm passing the string too and also the .text of UIInput.
But no luck.

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: UIInput, deleting buffer?
« Reply #1 on: November 28, 2012, 10:47:41 PM »
Hmm, well after a bit thought. I don't think this is possible.

For example, when the iPhone keyboard pops up, it already has its string present from before. So whether you clear it or not, the api from the external keyboard, there is surely no way NGUI or Unity can get at that information.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput, deleting buffer?
« Reply #2 on: November 29, 2012, 07:19:42 AM »
I don't quite understand your question. If the input field isn't focused, the label's text that you've given it will show up. Once you start typing, it gets replaced with what you're typing. If the input field loses focus, what you typed will remain there. Clearing the input field will once again make the original label's text show up. The intention is to make it easy to allow "press XYZ to start typing" kind of hints show up in input fields.

rchavarria

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: UIInput, deleting buffer?
« Reply #3 on: May 16, 2013, 10:29:05 PM »
I believe I hit this problem today.

When I dismiss the keyboard, then set the UIInput.text = string.Empty, the next time the keyboard is brought up, the Update() method of UIInput is going to check for Keyboard.text, and because it's different than what UIInput.text has, it will be set to the Keyboard's previous value.

My solution is to modify UIInput so mKeyboard.text = string.empty right before it is set to null

  1. if (mKeyboard.done)
  2. {
  3. mKeyboard.text = string.Empty;
  4. mKeyboard = null;
  5.  
  6. ...
  7. }

This solved all my problems with text cached in the Keyboard being re-set on the UIInput once it's re-activated.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput, deleting buffer?
« Reply #4 on: May 17, 2013, 01:24:54 AM »
When you dismiss the keyboard, it's destroyed, so why would it hold on to some value? What version of NGUI are you using?