Author Topic: UIInput to instantly convert to uppercase  (Read 3283 times)

madmat3001

  • Guest
UIInput to instantly convert to uppercase
« on: December 19, 2012, 03:52:08 PM »
I want an input field, that automatically converts the input to upper case as the user enters it.

I have succesfully implemented this by using the event listener for onInput and then calling ToUpper() on the Label.text.

But as soon as I click outside of the input area the text goes back to lower case and I don't know why.

Here's the code:
  1. [...]
  2. UIEventListener.Get(MyInputGameObject).onInput += InputToUpper;
  3. [...]
  4. private void InputToUpper(GameObject _sender, string _foo)
  5. {
  6.         MyInput.text = MyInput.text.ToUpper(); 
  7. }


madmat3001

  • Guest
Re: UIInput to instantly convert to uppercase
« Reply #1 on: December 19, 2012, 03:59:57 PM »
On a related note.

Upon submitting I want the input area to go back to empty.

So in the function referred to in UIInput "Function Name" I reset the Label.text.

But the text is not reset when I hit enter, even though the function is properly executed.

I also have a submit button next to the input area that triggers the same function. When I hit the button the text is properly reset. (Though it does flash back to the lower case version for a frame or so beforehand...)

dlewis

  • Guest
Re: UIInput to instantly convert to uppercase
« Reply #2 on: December 19, 2012, 05:53:15 PM »
I posted code to do this a while ago, I'll find the thread (I've been using it for months and it works perfectly).

Here is the thread I posted. All you have to do is tick 'Force caps' in the inspector (or through code) and then all text displayed will be in upper case (Just use lbl.text as normal)
« Last Edit: December 19, 2012, 05:55:16 PM by dlewis »