Author Topic: UIInput - bug on windows when entering polish character ą (Right Alt + a)  (Read 4087 times)

Presario

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
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 !!!


ArenMook

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

Presario

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
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.  
« Last Edit: August 13, 2014, 08:21:30 AM by Presario »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Ah, ok, that makes more sense then. CTRL+A... alright, I'll add a check for Alt.