Support => NGUI 3 Support => Topic started by: catlard on May 07, 2014, 02:22:47 AM
Title: UIKeybindings, UIInput, and UILabel's overflow styles.
Post by: catlard on May 07, 2014, 02:22:47 AM
Hi, everybody!
I'm trying to create a chat window where if the user wrote a longer string, the label would overflow to resize the height freely, so that if the user typed:
Thisis my question, I am writing a question, I am writing a question
And, as in the chat window example, it should not submit the message unless the user presses the return key.
However, the Chat Window example and other examples haven't shown me how this works. The Chat window example's UIInput's label seems to keep switching back to Shrink Content whenever I try to change it, and when I turn on the "Resize Height" overflow option with a UIKeyBinding set with the keycode to "Return" and the action to "Select", it just makes a newline in my chat window -- it doesn't seem to work. It seems to me that UIKeyBindings don't work on UILabels when the overflow style is not set to clampcontent -- because when I set it to clampcontent, hitting enter DOES actually submit it properly with the return key.
So, to be specific, my questions are: 1) How can I create a UIInput that submits when the user presses enter, but which has ResizeHeight set as its overflow option? 2) What do "Select" or "PressAndClick" mean, when we're talking about UIKeyBindingActions? I don't know what it means to select something in NGUI. Does it mean to "Submit"?
Cheers, thanks for your help, here's to a great product.
Simon
Title: Re: UIKeybindings, UIInput, and UILabel's overflow styles.
Post by: ArenMook on May 08, 2014, 01:23:39 AM
It's not Key Binding... it's the input itself. The UIInput is the one that handles the return key, and in case of a single line input -- calls the Submit function (which is what the key binding uses). Hitting Enter in a multi-line input will start a new line, while hitting Enter in a single-line input will call the submit function.
ChatInput script is what force-changes the max lines to be 1, forcing the label to be single line.
UInput is what checks the label -- if it's multi-line, it does one thing, if it's single line it does another. Line 854 of UIInput.cs.
After thinking about it for a bit I've decided to go ahead and add an explicit option on the UIInput that will control what the Return key will do. You will find it in the next update.
Title: Re: UIKeybindings, UIInput, and UILabel's overflow styles.
Post by: catlard on May 08, 2014, 07:32:57 AM
You're the man, once again. I will name my children after you. Their names, in order of birth, will be: