Author Topic: UIInput bugs in 3.0.8f3  (Read 9148 times)

schneidb

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 2
  • Posts: 24
    • View Profile
Re: UIInput bugs in 3.0.8f3
« Reply #15 on: March 10, 2014, 09:54:14 AM »
I should also clarify, that this also works to solve the problem we've been discussing...
  1.                         if (string.IsNullOrEmpty(ime) && !string.IsNullOrEmpty(Input.inputString))
  2.                         {
  3.                                 // Process input ignoring non-printable characters as they are not consistent.
  4.                                 // Windows has them, OSX may not. They get handled inside OnGUI() instead.
  5.                                 string s = Input.inputString;
  6.                                
  7.                                 for (int i = 0; i < s.Length; ++i)
  8.                                 {
  9.                                         char ch = s[i];
  10.                                         if (ch < ' ') continue;
  11.                                        
  12.                                         // OSX inserts these characters for arrow keys
  13.                                         if (ch == 63232) continue;
  14.                                         if (ch == 63233) continue;
  15.                                         if (ch == 63234) continue;
  16.                                         if (ch == 63235) continue;
  17.                                        
  18.                                         Insert(ch.ToString());
  19.                                 }
  20.                         }
  21.  

... but there is another problem that is only an issue in the editor that the first solution (from my previous post) also addresses.  That issue is that you can use Command+p on the keyboard to play and stop in the editor.  If you are in play mode in the editor while an NGUI UIInput field has focus, the 'p' part of Command+p is inserted into the field.

schneidb

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 2
  • Posts: 24
    • View Profile
Re: UIInput bugs in 3.0.8f3
« Reply #16 on: March 10, 2014, 04:02:48 PM »
I apologize, it would appear I'm being an idiot today as the code I proposed actually blocks all input.  This does work, however...
  1.                         if (string.IsNullOrEmpty(ime) && !string.IsNullOrEmpty(Input.inputString))
  2.                         {
  3.                                 // Process input ignoring non-printable characters as they are not consistent.
  4.                                 // Windows has them, OSX may not. They get handled inside OnGUI() instead.
  5.                                 string s = Input.inputString;
  6.  
  7.                                 for (int i = 0; i < s.Length; ++i)
  8.                                 {
  9.                                         char ch = s[i];
  10.                                         if (ch >= ' ' && ch != 63232 && ch != 63233 && ch != 63234 && ch != 63235) Insert(ch.ToString());
  11.                                 }
  12.                         }
  13.  

Sorry about that.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput bugs in 3.0.8f3
« Reply #17 on: March 10, 2014, 08:31:36 PM »
I don't see any difference between your last two functions logic-wise. The only difference is one does an equality check and the other does an inequality check.

Thinking about it, my code should have been using '\uF700' etc, as that's the correct hexadecimal representation.
  1.                         if (string.IsNullOrEmpty(ime) && !string.IsNullOrEmpty(Input.inputString))
  2.                         {
  3.                                 // Process input ignoring non-printable characters as they are not consistent.
  4.                                 // Windows has them, OSX may not. They get handled inside OnGUI() instead.
  5.                                 string s = Input.inputString;
  6.  
  7.                                 for (int i = 0; i < s.Length; ++i)
  8.                                 {
  9.                                         char ch = s[i];
  10.                                         if (ch < ' ') continue;
  11.  
  12.                                         // OSX inserts these characters for arrow keys
  13.                                         if (ch == '\uF700') continue;
  14.                                         if (ch == '\uF701') continue;
  15.                                         if (ch == '\uF702') continue;
  16.                                         if (ch == '\uF703') continue;
  17.  
  18.                                         Insert(ch.ToString());
  19.                                 }
  20.                         }

schneidb

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 2
  • Posts: 24
    • View Profile
Re: UIInput bugs in 3.0.8f3
« Reply #18 on: March 11, 2014, 04:42:02 AM »
Yes, this does indeed work.  It doesn't address the command+p issue I described, but that is an Editor only issue that I can live with.  Thanks!