Author Topic: [Solved: Must Be Coded] Back to line in UIInput.  (Read 3497 times)

Abnaxus

  • Guest
[Solved: Must Be Coded] Back to line in UIInput.
« on: July 11, 2013, 03:21:41 AM »
Hi there,

I've been searching for a moment now, how to go back to line when the user press "enter" in a UIInput ?
I've found some answers here, but the solution you provided (the one you included in a release) don't work on my side.
Since nobody's complaining, I guess I did something wrong.

Maybe you could lighten me ?

  1. else if (c == '\r' || c == '\n')
  2.                 {
  3.                     if (UICamera.current.submitKey0 == KeyCode.Return || UICamera.current.submitKey1 == KeyCode.Return)
  4.                     {
  5.                         // Not multi-line input, or control isn't held
  6.                         if (!label.multiLine)// || (!Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.RightControl)))
  7.                         {
  8.                                                         /*mText += "\n";
  9.                                                         UpdateLabel();
  10.                                                         return;*/
  11.                             // Enter
  12.                             current = this;
  13.                             if (onSubmit != null) onSubmit(mText);
  14.                             if (eventReceiver == null) eventReceiver = gameObject;
  15.                             eventReceiver.SendMessage(functionName, mText, SendMessageOptions.DontRequireReceiver);
  16.                             current = null;
  17.                             selected = false;
  18.                             return;
  19.                         }
  20.                     }
  21.  
  22.                     // If we have an input validator, validate the input first
  23.                     if (validator != null) c = validator(mText, c);
  24.  
  25.                     // If the input is invalid, skip it
  26.                     if (c == 0) continue;
  27.  
  28.                     // Append the character
  29.                     if (c == '\n' || c == '\r')
  30.                     {
  31.                         if (label.multiLine) mText += "\n";
  32.                     }
  33.                     else mText += c;
  34.  
  35.                     // Notify the listeners
  36.                     SendMessage("OnInputChanged", this, SendMessageOptions.DontRequireReceiver);
  37.                 }

Whatever I do, it always enter the
  1. if (!label.multiLine || (!Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.RightControl))
multiLine is ok (I mean, going to be false only if "maxLine = 1"), but the 2 others break everything and I don't even get what and why they are. :s

Thanks in advance,

Cheers,
Abnaxus.
« Last Edit: July 15, 2013, 03:03:43 AM by Abnaxus »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Back to line in UIInput.
« Reply #1 on: July 11, 2013, 07:22:30 PM »
How to go back to line? What?

If you're asking how you can enter a line break -- you can't. Input allows you to enter a single line. NGUI has an input field. it doesn't have a text box.

Abnaxus

  • Guest
Re: Back to line in UIInput.
« Reply #2 on: July 12, 2013, 03:04:27 AM »
Hmmm, ok.

Then I'll might want to change your code so it can handle line break.

But the problem is I can't find where you get the "current line number" variable, so I can compare it with maxLineNumber (the variable counting how many line you allow).
Or maybe you don't have and you only change the clip depending on the maxLine ?

Maybe you can help me with that ? :s

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Back to line in UIInput.
« Reply #3 on: July 12, 2013, 01:30:43 PM »
There is no "current line number". As I said, the input is not meant to have multiple lines. Visualization with a right alignment cuts off everything past certain width starting from the right. Is this what you're referring to? That code is on the label.

Abnaxus

  • Guest
Re: Back to line in UIInput.
« Reply #4 on: July 15, 2013, 03:02:54 AM »
There is no "current line number". As I said, the input is not meant to have multiple lines.
Ew ok, gonna have to code it then. I'll have a try.