Author Topic: Feature Request: Move input caret backards if the user typed a symbol  (Read 1286 times)

zippo227

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
Is there a way for a class inheriting from UIInput to know if the user has just typed a symbol? Presently I'm having to override some of the functionality to even show a symbol.

  1.        
  2. void Awake()
  3.         {
  4.             base.Init();
  5.  
  6.             UILabel lbl = this.GetComponentInChildren<UILabel>();
  7.             lbl.supportEncoding = true;
  8.             lbl.symbolStyle = NGUIText.SymbolStyle.Colored;
  9.         }
  10.  

I've noticed that when I do type a symbole such as :smile: the input caret does not back up to just after the smile emoticon. Any ideas on how I could accomplish this? A stretch goal would be to delete the emoticon and delete the entire :smile: from the input.

If I don't hear back, then I'll just have to have the users input their symbols manually by clicking on them instead of typing them.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Feature Request: Move input caret backards if the user typed a symbol
« Reply #1 on: January 27, 2015, 04:08:02 AM »
UIInput.onValidate is triggered for every single character typed into the input field. The returned value should be the character to actually add. Return '0' if you want to remove this character.