Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Kane

Pages: [1]
1
NGUI 3 Support / Re: Avoid line-break in UIInput
« on: October 22, 2014, 04:02:46 AM »
Had to check the UIInput.cs file to know how to ignore newlines, and I found this:

  1. case KeyCode.KeypadEnter:
  2.                         {
  3.                                 ev.Use();
  4.  
  5.                                 bool newLine = (onReturnKey == OnReturnKey.NewLine) ||
  6.                                         (onReturnKey == OnReturnKey.Default &&
  7.                                         label.multiLine && !ctrl &&
  8.                                         label.overflowMethod != UILabel.Overflow.ClampContent &&
  9.                                         validation == Validation.None);
  10.  
  11.                                 if (newLine)
  12.                                 {
  13.                     //Insert("\n");
  14.                                 }
  15.                                 else
  16.                                 {
  17.                                         UICamera.currentScheme = UICamera.ControlScheme.Controller;
  18.                                         UICamera.currentKey = ev.keyCode;
  19.                                         Submit();
  20.                                         UICamera.currentKey = KeyCode.None;
  21.                                 }
  22.                                 return true;
  23.                         }

So in order to avoid newlines, you need to do:

UILabelObject.multiLine = false;

UIInputObject.onReturnKey = UIInput.OnReturnKey.Default;


Doing that, bool newLine becomes false and performs Submit();


2
NGUI 3 Support / Avoid line-break in UIInput
« on: October 21, 2014, 07:39:50 PM »
Hello!

I am using the version 3.5.9, and I am wondering if there is any way to avoid users to input line-breaks in UIInputs.

Do not want the user to be able to write line-breaks in username inputs, for example.

I searched for multiline attribute but it seems it only exists in UILabel objects.

Tried "validation:Username" but this option does not allow to write characters like "-", which is a valid username character of my application.

Any idea to avoid line-break?

Thanks! : )

Pages: [1]