Tasharen Entertainment Forum

Support => NGUI 3 Documentation => Topic started by: ArenMook on November 22, 2013, 10:02:08 PM

Title: UIInput
Post by: ArenMook on November 22, 2013, 10:02:08 PM
Overview

UIInput is a script that makes it possible to type in an area, allowing you to create input fields and editable text boxes.

(http://www.tasharen.com/ngui/uiinput.jpg)

To create an input field, just add it to any clickable area and choose a Label that it will be modifying.

The most basic setup for an input field would be a sliced Sprite (http://www.tasharen.com/forum/index.php?topic=6704) for the background (or a Widget (http://www.tasharen.com/forum/index.php?topic=6702) if you want it to be invisible), and a child Label (http://www.tasharen.com/forum/index.php?topic=6706) for the foreground. In this example, the sprite would need a Box Collider in order to receive events, and the UIInput script would go onto it as well:

Quote
Clickable Area (UISprite, BoxCollider, UIInput)
- Text (UILabel)

This setup is all that's needed in order to be able to click on the input field and start typing.

You can give your Input Field a Starting Value if you like, and you can also make it automatically save its value by giving it a key in the Saved As field. If specified, the value you typed will be persistent. Most obvious usage of this would be for a Player Name or a Username field.

You can set the inactive text on the input field by modifying the text of the label itself. This includes the label's color. So if you wanted a half-faded out "press here to start typing" text to be visible when the input field has no text in it, enter that text on your label and set the label's color to be half-transparent (or just modify the Inactive color field on the UIInput).

When the input field gets selected, the label's text will be replaced, and its color will be changed to the Active Text color value specified on the UIInput.

You can change the Input Type of your input if you need it to be a Password Field, or if you want there to be auto-correcting behaviour on mobile platforms. The Keyboard Type is also there for mobile platforms, as it controls what kind of keyboard will show up when you select the input field.

If you want the input field to have some basic validation, such as making it accept only Integer values, set it using the Validation option. You can likewise limit the number of characters that the user will be allowed to enter using the Character Limit field. Leaving it at zero removes the character limit.

To allow your user to use Tab to navigate to the next field, drag & drop the next input field into the Select On Tab field.

To change the alignment of your input field, modify it on the Label itself. You can similarly limit your input field to a single line by setting the Max Lines property to 1 on the UILabel (http://www.tasharen.com/forum/index.php?topic=6706). The same goes for all the other options on the label, such as giving it a gradient, a shadow effect, or changing the character spacing.

Note that in most cases you will likely want to leave your label's Overflow handling on ClampContent, as this will allow the input to automatically scroll to the right as the user keeps typing past the original bounds.

To receive a notification of when the user submits the text in the input field, take advantage of its On Submit notification section. You can always retrieve the input field's value within the function you're calling by using UIInput.current.value. After you're done processing the callback you can set the UIInput.current.value to null to clear the input field's text:
  1. public void MySubmitFunction ()
  2. {
  3.     Debug.Log("I typed: " + UIInput.current.value);
  4.     UIInput.current.value = null;
  5. }

Pro-Tip

If you want to be able to select your input field when pressing a specific key, such as hitting "Enter" to start typing in your chat window, attach a UIKeyBinding (http://www.tasharen.com/forum/index.php?topic=6753) script to it.

(http://www.tasharen.com/ngui/uikeybinding.jpg)

Class Documentation

http://tasharen.com/ngui/docs/class_u_i_input.html

If you have a question regarding this component or would like me to clarify something, just post a reply here.
Title: Re: UIInput
Post by: Haim on December 11, 2013, 03:48:50 PM
what about move from one input box to the next with TAB button? how can i do that?
Title: Re: UIInput
Post by: ArenMook on December 12, 2013, 05:57:37 AM
That's specified on the UIInput (http://www.tasharen.com/forum/index.php?topic=6752.0).
Title: Re: UIInput
Post by: Haim on December 14, 2013, 09:26:07 AM
i read this again, don't see any thing about TAB. only ENTER to start type...
i have two UIinpus fields and i want to use TAB to jump from one field to other.

also, the UIinput configuration  in 3.0.7 looks different then what i see in the image here. (not updated?)
the image here missing the "Select on tab" option but i'm not sure how it works.
it asking to attach game object, i attached the parent of both UIinput but nothing happen.
Title: Re: UIInput
Post by: ArenMook on December 14, 2013, 07:30:23 PM
The only thing missing in the screenshot is the "Select On Tab" field, which is coincidentally what you were asking about. Set it to some game object (like the next input field) and it will be selected when you hit Tab.

If you look at Example 0 that comes with NGUI, the two input areas have each other set in the Select On Tab fields, which lets me tab from one to the other.

I've updated the screenshot.
Title: Re: UIInput
Post by: indiefreaks on December 15, 2013, 07:14:24 PM
Would love to see some Pro tips about custom validation on a per UIInput field basis ;)

Thanks
Title: Re: UIInput
Post by: zippo227 on January 04, 2014, 06:09:26 PM
I recently updated and noticed that my input is no longer submitting. I want the label to be able to spread across multiple lines (instead of overflowing to the right) but still submit when the user presses Enter. Is there still a way to do that? I notice that now you've changed it to add a \n
Title: Re: UIInput
Post by: ArenMook on January 05, 2014, 09:14:27 AM
Change the label to use Max Lines of 1.
Title: Re: UIInput
Post by: 47giga on January 06, 2014, 10:01:15 AM
Hi, I am using NGUI 3.0.7 and don't know how to get new value before submitting it in UIInput.
(The value in the inspector is changed but cannot get it until submit)
Title: Re: UIInput
Post by: ArenMook on January 06, 2014, 10:43:10 AM
I don't understand what you're asking. UIInput.current.value tells you the value inside your OnSubmit. What does it have to do with "before submitting"?
Title: Re: UIInput
Post by: 47giga on January 06, 2014, 12:31:51 PM
Thanks. I tried the following line but it caused the following error on Unity.

code:
void Update (){ Debug.Log(UIInput.current.value);}

error:
NullReferenceException: Object reference not set to an instance of an object
myInput.Update () (at Assets/myInput.cs:12)

----
I also tried the following code for onSubmit but it is never called without typing return. I meant it as "before submitting it"
public void valueTest(){Debug.Log(UIInput.current.value);}

----
P.S. I solved my problem by getting the value by the following line instead of UIInput.current.value so it is not problem anymore but I write my solution as FYI.
void Update (){Debug.Log(this.GetComponent<UIInput>().value); }
Title: Re: UIInput
Post by: ArenMook on January 06, 2014, 06:38:09 PM
UIInput.current is only valid inside the OnSubmit delegate callback. It will remain null everywhere else.
Title: Re: UIInput
Post by: Ernest on January 07, 2014, 05:03:24 AM
So if i want to get the input field value in the onClick event of a button, how do i do?
Title: Re: UIInput
Post by: ArenMook on January 07, 2014, 08:59:22 AM
Button won't know anything about your input, so it's up to you to find it somehow.

If you hit Enter to submit text in the input field, then UIInput.current will contain the reference of the input field that triggered the OnSubmit event.
Title: Re: UIInput
Post by: Ernest on January 07, 2014, 10:10:18 AM
Yep i got that. My issue is, if i have a "Submit" function (doing any process) using UIInput.current.value, i have no problem by setting it in the OnSubmit field in the UIInput inspector (so when i press the return key) but it failed when i set it in the OnClick field in the UIButton inspector (for the reason you exposed). So there is no simple/inspector way to do my input related process by clicking on this button? (I have to get the label value in my "Submit" function instead of UIInput.current.value?) Thanks

EDIT: thanks for the trick below :)
Title: Re: UIInput
Post by: ArenMook on January 08, 2014, 01:57:21 PM
If you make UIInput.Submit() a public function then you can choose it in the inspector under UIButton's On Click notification.
Title: Re: UIInput
Post by: CBYum on January 17, 2014, 11:53:29 AM
Just downloaded 3.0.8 after seeing that it has better input handling, but we don't see anything different on mobile devices (other than how the caret is handled). Is there some switch we need to use or does this mean that these enhancements are PC or other platforms only?

Also had to change the order of setting the UIInput.value and the UILabel.text it refers to. Setting the text THEN value errored but reversing them fixed it. (If I don't explicitly set the UIInput.value the same as label the entry field gets refilled with the last edited text rather than the last set value of the label.). This is all on Android at the moment.

Thanks
Title: Re: UIInput
Post by: ArenMook on January 18, 2014, 10:30:57 PM
The enhancements are for the desktop platforms. Mobiles have their own input field, which is why it didn't make much sense to have both functionality.
Title: Re: UIInput
Post by: arumons on January 22, 2014, 11:02:05 PM
I want to distinguish "close keyboard"(touch not keyboard area) and pressing OK button on Android device.
However, submit that will be called in case of both.
(In case of both, mKeyboard.done is true and mKeyboard.wasCanceled is false in Update function...) :'(

Title: Re: UIInput
Post by: ArenMook on January 23, 2014, 07:11:48 AM
Yup, it's a Unity bug. I suggest reporting it.
Title: Re: UIInput
Post by: MOST2K2 on January 28, 2014, 09:08:44 AM
I use this widget in my android Project, but when the Keyboard opens the text is selected, how can i disable selection? after hit 'done' on the Keyboard the two selection marker are still there see this Picture http://3.bp.blogspot.com/-6qRC_rfbBmc/TqOmKistjdI/AAAAAAAABKA/QnJ-UwerDc8/s1600/copypaste.jpg
Title: Re: UIInput
Post by: ArenMook on January 28, 2014, 11:36:07 AM
NGUI has nothing to do with the system input. Even Unity has little to do with it. That's your device's OS.
Title: Re: UIInput
Post by: MOST2K2 on January 28, 2014, 01:18:04 PM
but after the keyboard is closed it looks like this (see attachment)...thats why i dont want to have selected the text automatically.
Title: Re: UIInput
Post by: ArenMook on January 29, 2014, 10:45:13 AM
Can't say I've ever seen anything like that on any of the mobile devices I have. Are those the system's selection arrows remaining behind when you close the keyboard? That just seems like some bug with the version of the OS your device uses.
Title: Re: UIInput
Post by: MOST2K2 on January 29, 2014, 04:50:47 PM
yes that are the system's selection arrows when the keyboard closes, you have to selected some test before close. i have the nexus 5 with kitcat 4.4.
is there any way to prevent selection when keyboard opens?
Title: Re: UIInput
Post by: ArenMook on January 29, 2014, 11:12:59 PM
NGUI doesn't pass any selection information to the OS. Just the text. Look inside UIInput line 392.
Title: Re: UIInput
Post by: hrlarsen on February 04, 2014, 03:40:39 PM
I would love to see that the UIInput field had the same properties on mobile as it has on desktop, especially with caret and placing the caret on press etc. This feature however would only be relevant when setting TouchScreenKeyboard.hideInput = true as this hides the normal input field on the mobile device.

I do not know if this is possible already? because then I would love to hear how

Title: Re: UIInput
Post by: Kingtem on February 17, 2014, 04:43:10 AM
Hi Aren,
      My NGUI 3.4.9 dosen't show the "Select on Tab". I tried import NGUI into different project but the same result, then I open the "UIInputField" script, which the variabe is correct but just dont show itself in inspector, its strange...... :-\
Title: Re: UIInput
Post by: ArenMook on February 17, 2014, 01:48:45 PM
It doesn't show in inspector? It's between "Selection Color" and "Input Type" fields.
Title: Re: UIInput
Post by: Kingtem on February 18, 2014, 04:07:16 AM
Yes, I've tried many times. Besides, if I create a new variable(Any type) next to "selectOnTab", the variable dosen't show in inspector too.
Title: Re: UIInput
Post by: ArenMook on February 18, 2014, 10:53:28 AM
Simply adding variables to the class won't make them show up in inspector because NGUI uses custom editor scripts. You'd need to add them to the editor classes as well. Look at UIInputEditor.cs.
Title: Re: UIInput
Post by: Kingtem on February 19, 2014, 04:36:54 AM
Thank you Aren! So is that the same reason to make "selectOnTab" dosen't show?
Title: Re: UIInput
Post by: ArenMook on February 20, 2014, 12:52:35 PM
Select on Tab field only shows up on non-mobile platforms. Target stand-alone, and you will see it.
Title: Re: UIInput
Post by: Kingtem on February 25, 2014, 08:20:54 PM
Yes, thats the point, the problem was solved by switch to standalone platform. Thank you!
Title: Re: UIInput
Post by: nkls on March 04, 2014, 05:58:16 AM
I have an input field controlled by a custom made keyboard. How do I focus my input field without selecting the text in it? I just want to show the carot at the current position in the text, without selecting the text itself. 
Title: Re: UIInput
Post by: sunspider on March 04, 2014, 11:24:44 PM
I want focus to go to the next UIInput in the tab order when the user presses ENTER, to allow quick entry of a bunch of fields. Could not figure out a way to do that with NGUI components. Am interested if there is a good way to achieve this... I ended up getting the behavior I wanted by hacking the bottom part of this into the UIInput.cs ProcessEvent method...

  1.                         // Submit
  2.                         case KeyCode.Return:
  3.                         case KeyCode.KeypadEnter:
  4.                         {
  5.                                 ev.Use();
  6.                                
  7.                                 if (label.multiLine && !ctrl && label.overflowMethod != UILabel.Overflow.ClampContent)
  8.                                 {
  9.                                         Insert("\n");
  10.                                 }
  11.                                 else
  12.                                 {
  13.                                         UICamera.currentScheme = UICamera.ControlScheme.Controller;
  14.                                         UICamera.currentKey = ev.keyCode;
  15.                                         Submit();
  16.                                         UICamera.currentKey = KeyCode.None;
  17.                                 }
  18.         // HACK: INSERTED THIS BIT HERE:
  19.                                 if (selectOnTab != null) {
  20.                                         UICamera.selectedObject = selectOnTab;
  21.                                 }
  22.                                 return true;
  23.  
  24.                         }
Title: Re: UIInput
Post by: ArenMook on March 06, 2014, 12:04:26 PM
I have an input field controlled by a custom made keyboard. How do I focus my input field without selecting the text in it? I just want to show the carot at the current position in the text, without selecting the text itself.
If you wanted to set the selection yourself, you will need to expose mSelectionStart / mSelectionEnd and call UpdateLabel() after changing them.
Title: Re: UIInput
Post by: ArenMook on March 06, 2014, 12:12:07 PM
@sunspider: You don't need to modify NGUI for that. You can just set a function to be called in On Submit section. Inside that function set
  1. UICamera.selectedObject = UIInput.current.selectOnTab;
Title: Re: UIInput
Post by: sunspider on March 06, 2014, 03:43:22 PM
You can't go to next field on submit, because there is a conflict when I submit with the tab or down arrow key... which is another standard behavior of forms.

Not sure if I am being clear... the change I am trying to make is as follows:
1) ANY time a control loses focus, it will submit.
2) DOWN, TAB, and ENTER all automatically move to next field.

Made down arrow and tab work with the Button Keys component on UIButtons and the selectOnTab on UIInputs. Had to tell it specifically to update on Deselect with the UI Event Trigger. Then I had to hack in that code to make ENTER work.

I have this working, but it was quite roundabout to achieve this sort of standard entry behavior... is there a more straightforward way? This is how almost all forms work.
Title: Re: UIInput
Post by: nkls on March 07, 2014, 03:42:48 AM
If you wanted to set the selection yourself, you will need to expose mSelectionStart / mSelectionEnd and call UpdateLabel() after changing them.

Thanks for answering, great support as always. Is it possible to implement this as an option in a future update? Maybe a "select text at focus"-checkbox or something.
Title: Re: UIInput
Post by: ArenMook on March 07, 2014, 10:58:02 AM
@sunspider: If you want it to submit when you deselect, just call the input field's submit function in OnSelect(false) of a script attached to the same object as your input.

@nkls: I can certainly expose it in a future update.
Title: Re: UIInput
Post by: nkls on March 19, 2014, 05:05:06 AM
a quick request:
when selecting an input field, it clears itself. i would like an option that keeps the default text until you actually write something into the field.
we┬┤ve changed this line
  1. processed = selected  ? "" : mDefaultText;
to
  1. processed = selected && !KeepDefaultTextOnFocus ? "" : mDefaultText;
where KeepDefaultTextOnFocus is a public bool.

Title: Re: UIInput
Post by: Tripwire on March 20, 2014, 10:15:45 AM
I'm using the latest version of NGUI (3.5.4R2) and it seems that the input is broken :(. I have some textfields which should have multiple lines. I have set the UIInput overflow to clamp but when i'm writing in the TextFields it doesn't auto enter when coming at the end of the clamp field :(

EDIT:
When I press ENTER it isn't going to the next line in the textfield anymore so that isn't working either.
Title: Re: UIInput
Post by: ArenMook on March 20, 2014, 01:13:14 PM
If the label content is set to "clamp" then the input field will be single-line. If you want it to be multi-line, use "shrink to fit".
Title: Re: UIInput
Post by: Tripwire on March 20, 2014, 05:31:00 PM
If the label content is set to "clamp" then the input field will be single-line. If you want it to be multi-line, use "shrink to fit".

Thx for your reply i've tried setting it to shrink to fit but then the text just shrinks when it comes to the end of the texfield. Also the example prefab texfield does not work like it should be. Same problem as described above.

EDIT:

Created a new project, imported NGUI and created a new 2D UI added a panel and added the Control - Simple Text Box prefab to the panel. Didn't change any settings whatsoever. Textbox is not auto entering when it reaches the end of the box. It just shrinks te text. Tried setting it to Clamp content, didn't work either.
Title: Re: UIInput
Post by: ArenMook on March 21, 2014, 04:15:37 PM
The shrinking is intentional, thats what should happen when the text exceeds the bounds. Those are the two types of input supported -- either it's clamped and single line, or it's multi-line but automatically shrinks when the content exceeds the bounds.
Title: Re: UIInput
Post by: pretender on April 01, 2014, 04:52:36 AM
How "Saved As" is used? Can you help me?
Title: Re: UIInput
Post by: ArenMook on April 01, 2014, 10:56:40 AM
"Saved As" is currently bugged in 3.5.5. From the patch notes of 3.5.6:
Quote
- FIX: UIInput will now load the saved value properly even if the "starting value" is not empty.
Title: Re: UIInput
Post by: pretender on April 01, 2014, 11:20:10 AM
Is it read from player prefs? Or i am missing something. Cant wait for next release
Title: Re: UIInput
Post by: ArenMook on April 03, 2014, 09:55:53 PM
I don't remember what the issue was... I just know there was an issue and it got fixed. :P
Title: Re: UIInput
Post by: gonzosan on April 06, 2014, 02:46:52 PM
Hello,

I just got NGUI a few days ago and I'm trying to use the input boxes so that a user can input a number then output it into the chat area I've designated. I've figured out how to do all that with just numbers (it tracks number values). The thing I'm having an issue with is how I can have it update every time a number is put in. What I'd like to do is have the numbers add up every time a new number is put in. I'm not sure how to go about this. I'm familiar with adding and subtracting integers in a script but not sure how to get the output to add up to a total that is constantly changing. For context I'm trying to build a health app, so users would keep track of calories throughout the day. They'd input calories for every meal and the total would update to reflect the new total. Any help is greatly appreciated.
Title: Re: UIInput
Post by: gonzosan on April 07, 2014, 11:13:06 AM
Alright so I just realized I can add scripts to my GUI objects and have the functions show up in the drop down menus. I used the function used on the first page of this thread ("MySubmitFunction"). It works as it should but how can I get it to show up in the chat area? If I use the OnSubmit function it'll show up just fine. Do I need to edit the ChatInput script and use that instead? Thanks.
Title: Re: UIInput
Post by: ArenMook on April 08, 2014, 01:25:33 AM
Input can be restricted to numeric-only input by choosing the appropriate Validation method.

All functions will show up as long as the are public.
Title: Re: UIInput
Post by: gonzosan on April 08, 2014, 09:57:48 AM
I have everything setup I'm just having issues adding the numeric values on the output side. I'm not sure what I need to modify. I'm playing around with "OnSubmit" function to get it to add numbers but it just displays them as a string. I know I need to change that but not sure if it's an issue within ChatInput or the textlist script. It's something simple but I'm having a hard time seeing what the issue is. Thanks for the help.
Title: Re: UIInput
Post by: ArenMook on April 09, 2014, 04:14:38 AM
I don't quite understand your post. What does OnSubmit have to do with any of this? I said set the appropriate Validation method on the UIInput.
Title: Re: UIInput
Post by: gonzosan on April 10, 2014, 11:53:07 AM
I need to add numbers when I hit submit. I have set the validation method in the settings in the inspector panel under the UIInput script, that's not an issue. That just makes it so that you can only input numbers but the output still acts like a string. So if I try to add whatever I input to another value it just shows up as a string. So for instance if I input 10 into the input box and go into the OnSubmit function and say
  1.  textList.Add(text + 12);

It displays as "1012". I want these numbers to add/subtract so what is the best way to do this?
Title: Re: UIInput
Post by: ArenMook on April 11, 2014, 07:54:47 AM
Like any other way of converting a string to an int in C#:
  1. int intValue;
  2. int.TryParse(stringValue, out intValue);
Title: Re: UIInput
Post by: vinfang on May 09, 2014, 07:12:06 PM
Is it possible for the UIInput and UILabel to perform a multi-line text wrap for user input? The combinations I'm trying to use between UIInput and UILabel only give me text that shrinks or it stays on one line but can go on forever.

EDIT: So for version 3.5.8, I edited the file UIInput.cs file by commenting out

1109  //if (offset > mDrawStart)
1110 //{
1111     //mDrawStart = offset;
1112     //SetPivotToRight();
1113 //}

And

1116  // If necessary, trim the front
1117  //if (mDrawStart != 0)();
1118  //processed = processed.Substring(mDrawStart, processed.Length - mDrawStart);

and with UIInput script having the character limit set to 0 and in the UILabel the Overflow is set to ClampContent and Alignment is set to Left, the text when I type it in to the Input text area I created allows text wrap with mult-lining.

Are these changes ok? So far things seem to work.
Title: Re: UIInput
Post by: ArenMook on May 09, 2014, 08:28:03 PM
3.5.9 supports it natively, but if your changes work fine for you then that's ok.
Title: Re: UIInput
Post by: vinfang on May 23, 2014, 03:49:02 AM
I imported version 3.6.0 and tried out the new UIInput along with a UILabel to see if clamp content, multiline support worked as I typed in words into a UIInput and it doesn't multiline still. It just keeps going on forever on one line.

On the UIInput I have Standard InputType, default on return key, default keyboard type, and a 200 character limit. On the UILabel I pointed the UIInput to, the overflow is set to clampcontent, alignment is automatic, and max lines is 7.

Am I setting something wrong in either one of those scripts?
Title: Re: UIInput
Post by: ArenMook on May 23, 2014, 05:25:53 PM
Change line 1121 of UIInput.cs from:
  1. if (selected && label.overflowMethod == UILabel.Overflow.ClampContent)
to:
  1. if (selected && label.overflowMethod == UILabel.Overflow.ClampContent && label.maxLineCount == 1)
Title: Re: UIInput
Post by: Tripwire on May 27, 2014, 07:11:19 AM
Hi ArenMook,

Question about the a textfield. I have a textfield setup with multi-line enabled. I've set the TouchScreenKeyboard.hideInput to true. But when inputting text in te textfield it still shows the text input above the keyboard. When I set the max lines to 1 it's not showing the text input above the keyboard but i can't input multi-line texts.
Any idea how to fix this?
Title: Re: UIInput
Post by: maufournier on May 27, 2014, 11:09:06 AM
Hey ArenMook, I've been trying to set SelectOnTab, but it doesn't show up for me in the inspector. Why can't I see it?

I'm on 3.6.1c
Title: Re: UIInput
Post by: ArenMook on May 28, 2014, 07:53:50 AM
Switch to a non-mobile platform.
Title: Re: UIInput
Post by: maufournier on May 28, 2014, 09:55:45 AM
Ohhhhh that makes sense =P Thanks!!
Title: Re: UIInput
Post by: Tripwire on June 01, 2014, 03:36:54 PM
Hi ArenMook,

Question about the a textfield. I have a textfield setup with multi-line enabled. I've set the TouchScreenKeyboard.hideInput to true. But when inputting text in te textfield it still shows the text input above the keyboard. When I set the max lines to 1 it's not showing the text input above the keyboard but i can't input multi-line texts.
Any idea how to fix this?

Any idea?
Title: Re: UIInput
Post by: ArenMook on June 01, 2014, 06:31:25 PM
"Hide input" option is specified on the UIInput itself. You don't need to write code to hide it.
Title: Re: UIInput
Post by: Tripwire on June 02, 2014, 02:13:14 AM
"Hide input" option is specified on the UIInput itself. You don't need to write code to hide it.

I know that's the case in the latest version but i'm using 3.5.9f1 which doesn't have the option.

EDIT:
I updated to the latest version. I've set the UIInput keyboard type to HiddenInput. But how do I set the keyboard to HiddenInput and change it to NumberPad? So keyboard type then should be HiddenInput and NumberPad.
Title: Re: UIInput
Post by: ArenMook on June 02, 2014, 11:47:06 PM
I'll change it to make it possible for the next version. 3.6.2 only allows you to have the default keyboard type if it's using hidden input.
Title: Re: UIInput
Post by: Timberoth on June 08, 2014, 04:17:03 PM
Hi ArenMook,

I was wondering if it was possible to have the UIInput set to HiddenInput but also keep around Android's native word suggestion functionality which shows up right above the keyboard. I've attached an image for reference.  We're working on chat functionality and having the word suggestion along with cut/copy/paste functionality would be super useful.

Thanks,
Tim

Title: Re: UIInput
Post by: ArenMook on June 09, 2014, 03:41:52 AM
That would be a question for Unity, I'd say. If you can get it using TouchScreenKeyboard.Open, then sure, you can do the same thing in NGUI as that's what it uses in UIInput.cs.
Title: Re: UIInput
Post by: daybson on July 25, 2014, 01:36:30 PM
Hi,
I need to make a label show "typing..." when user is typing some text on the UIInput, and show other thing when doesn't. There's some method that provides this status like "typing" to me?

Thanks
Title: Re: UIInput
Post by: ArenMook on July 26, 2014, 03:48:18 AM
Write a script that sets the text in OnSelect(true) to one thing, OnSelect(false) to another.
Title: Re: UIInput
Post by: CADdev on July 31, 2014, 03:25:01 AM
Hello,

I have the same problem as Tripwire, so I have a text field with:
 - UILabel.maxLines = 0 (multi-line)
 - UIInput with hideInput = true

The problem is that on Android devices the native input field above the keyboard is still shown, even if hideInput = true. Setting maxLines to 1 will hide the native input field.
Is this an NGUI issue or a Unity issue?

Thanks for the reply.
Title: Re: UIInput
Post by: ArenMook on July 31, 2014, 12:45:05 PM
If the input is multi-line then you can't hide it. There are some OS/Unity bugs that prevent it from working properly from what I recall.
Title: Re: UIInput
Post by: Spirit117 on August 07, 2014, 03:38:02 AM
Hi.

Is there a way to make it so when a window opens, I can have the input field I want be auto-selected?
For example, a way to simulate a mouse click on that particular field for OnEnable(), or maybe an inherent setting?
Title: Re: UIInput
Post by: ArenMook on August 07, 2014, 04:11:15 AM
Just select it via UICamera.selectedObject = yourInput.gameObject in script's OnEnable().
Title: Re: UIInput
Post by: Spirit117 on August 10, 2014, 08:15:27 AM
You are my champion.
Title: Re: UIInput
Post by: DulcetTone on August 14, 2014, 11:46:22 AM
Just starting, but I find myself wishing there were an OnLostFocus() event.  I'd like to process the text input as soon as the user tabs away to the next field.

Would it be simple for me to make RemoveFocus() have a callback list, as does Submit()?

tone
Title: Re: UIInput
Post by: ArenMook on August 15, 2014, 08:13:30 AM
That's OnSelect (false). Use UIEventTrigger to trigger some remote function the same way OnSubmit works in the input field.
Title: Re: UIInput
Post by: TokyoDan on August 30, 2014, 09:09:14 PM
For the UIInput validation I know what kind of input the none, Integer, Float, Alphanumeric allow. But what do the Username and Name allow/disallow?
Title: Re: UIInput
Post by: ArenMook on August 31, 2014, 03:27:48 PM
Username makes it all lowercase and restricts it to alphanumerics I believe. Name allows spaces, and capitalizes the first letter of each word.
Title: Re: UIInput
Post by: zippo227 on January 28, 2015, 02:18:34 AM
Can you add a field to enable ctrl+a / cmd+a  to select all text?
Title: Re: UIInput
Post by: ArenMook on January 28, 2015, 02:40:39 AM
A field for that? Why? It's the default and expected behaviour of input fields.
Title: Re: UIInput
Post by: zippo227 on January 28, 2015, 03:53:04 AM
I agree, but it's not working, even in your example scenes. version 3.7.8 in Unity Editor 4.6.1 on Windows.
Title: Re: UIInput
Post by: ArenMook on January 29, 2015, 01:25:35 PM
It's all working fine for me on Windows stand-alone and Editor both, 3.7.9 in Unity 4.5.5
Title: Re: UIInput
Post by: zippo227 on January 29, 2015, 01:48:34 PM
After looking into my build, I am also on 3.7.9. It's just that the Readme does not show the version num 3.7.9. Perhaps you need to look at Unity 4.6.1. Are there any Keyboard inputs that I may have set in my Unity project that would override your functionality for ctrl+a
Title: Re: UIInput
Post by: ArenMook on January 30, 2015, 03:02:04 PM
Seems Unity broke a bunch of stuff in 4.6.1.

http://www.tasharen.com/forum/index.php?topic=12421.0
Title: Re: UIInput
Post by: zippo227 on February 04, 2015, 12:47:05 AM
I do understand that it was a big change in Unity, but as per your advice I always keep everything up to date to the bleeding edge.
Title: Re: UIInput
Post by: ArenMook on February 05, 2015, 01:09:28 PM
I had a look at 4.6.1 and CTRL+A doesn't work in the editor, but it does work fine when you do a build.
Title: Re: UIInput
Post by: yo_milo on February 12, 2015, 07:18:58 PM
Just as a curiosity. Why do you have a public remove focus, but not a public focus?
Title: Re: UIInput
Post by: ArenMook on February 13, 2015, 08:58:36 AM
The description above the function explains:
  1.         /// <summary>
  2.         /// Convenience function to be used as a callback that will clear the input field's focus.
  3.         /// </summary>
It's meant to be called from some delegate set in Inspector.

When using code, use UIInput.isSelected.