Author Topic: UIInput  (Read 91876 times)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput
« Reply #30 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.

Kingtem

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: UIInput
« Reply #31 on: February 19, 2014, 04:36:54 AM »
Thank you Aren! So is that the same reason to make "selectOnTab" dosen't show?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput
« Reply #32 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.

Kingtem

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: UIInput
« Reply #33 on: February 25, 2014, 08:20:54 PM »
Yes, thats the point, the problem was solved by switch to standalone platform. Thank you!

nkls

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: UIInput
« Reply #34 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. 

sunspider

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: UIInput
« Reply #35 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.                         }

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput
« Reply #36 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput
« Reply #37 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;

sunspider

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: UIInput
« Reply #38 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.

nkls

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: UIInput
« Reply #39 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput
« Reply #40 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.

nkls

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: UIInput
« Reply #41 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.


Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: UIInput
« Reply #42 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput
« Reply #43 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".

Tripwire

  • Full Member
  • ***
  • Thank You
  • -Given: 9
  • -Receive: 0
  • Posts: 163
    • View Profile
Re: UIInput
« Reply #44 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.
« Last Edit: March 21, 2014, 03:51:12 AM by Tripwire »