Author Topic: UIKeybindings, UIInput, and UILabel's overflow styles.  (Read 3704 times)

catlard

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 24
    • View Profile
UIKeybindings, UIInput, and UILabel's overflow styles.
« 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:

  1. This is my question, I am writing a question, I am writing a question

It would appear on seperate lines, as such:

  1. This is my question, I
  2. am writing a question,
  3. 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

« Last Edit: May 07, 2014, 06:59:23 AM by catlard »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIKeybindings, UIInput, and UILabel's overflow styles.
« Reply #1 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.

catlard

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: UIKeybindings, UIInput, and UILabel's overflow styles.
« Reply #2 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:

ArenMook,
CodeSlayer,
and Savior.

That is all.