Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Presario on August 12, 2014, 08:51:42 AM

Title: UIInput - bug on windows when entering polish character ą (Right Alt + a)
Post by: Presario on August 12, 2014, 08:51:42 AM
Hi there !

There is an UIInput bug on windows, probably related to Unity bug (?), which recognise Right Alt as Alt and Control. In result when User enters polish letter 'ą' (Right Alt + a) UIInput selects all content of input and overrides it with 'ą' letter which is obviously not intended.
To work around this issue I propose small change to UIInput::ProcessEvent method

  1. ...
  2.                 bool shift = ((ev.modifiers & EventModifiers.Shift) != 0);
  3. +               #if UNITY_STANDALONE_WIN
  4. +               if ( (ev.modifiers & EventModifiers.Alt) != 0 && (ev.modifiers & EventModifiers.Control) != 0  )
  5. +                       ctrl = false;
  6. +               #endif
  7. +
  8.                 switch (ev.keyCode)
  9.                 {
  10.                         case KeyCode.Backspace:
  11. ...
  12.  

Maybe there is better way to overcome this problem, but as workaround it works for me.
ArenMook, Can you include a fix in NGUI release which handles this issue correctly ?

Thanks !!!

Title: Re: UIInput - bug on windows when entering polish character ą (Right Alt + a)
Post by: ArenMook on August 13, 2014, 07:07:52 AM
I don't quite understand your proposed fix... if alt and control are both held, consider control as not held? What results in the selection to begin with? Neither alt nor control would cause selection. Holding Shift and using Home/End keys would though.
Title: Re: UIInput - bug on windows when entering polish character ą (Right Alt + a)
Post by: Presario on August 13, 2014, 08:14:42 AM
I don't claim that my fix is perfect it is just workaround on windows for processing Right Alt key + A key.
In this situation unity produce Event with Event.modifiers set to EventModifiers.Alt and EventModifiers.Control ... which should be only EventModifiers.Alt (i assume this is a Unity bug) so it is recognized by UIInput as unintended Control + A which selects whole text and overits it with "ą" letter, so application of UIInput as chat input is quite problematic that entering "ą" will delete all you message.
Proposed fix tries to discover situation when Right Alt is held (of course it cannot distinguish between Control + Alt and Right Alt) and considers control as not held which is true in this situation because only Right Alt is held not a control.
If you don't find betted way, maybe better is to fix this in KayCode.A section like this:
  1. ...
  2.                         // Select all
  3.                         case KeyCode.A:
  4.                         {
  5.                                 if (ctrl && (ev.modifiers & EventModifiers.Alt) == 0)  /// <=====  added chack for ALT key not held
  6.                                 {
  7.                                         ev.Use();
  8.                                         mSelectionStart = 0;
  9.                                         mSelectionEnd = mValue.Length;
  10.                                         UpdateLabel();
  11.                                 }
  12.                                 return true;
  13.                         }
  14. ...
  15.  
Title: Re: UIInput - bug on windows when entering polish character ą (Right Alt + a)
Post by: ArenMook on August 14, 2014, 06:39:41 AM
Ah, ok, that makes more sense then. CTRL+A... alright, I'll add a check for Alt.