2
0
Эх сурвалжийг харах

Fixed more netdriver key issues (tab)

Tig 1 жил өмнө
parent
commit
06f7a74aa0

+ 22 - 13
Terminal.Gui/ConsoleDrivers/NetDriver.cs

@@ -1583,6 +1583,27 @@ internal class NetDriver : ConsoleDriver
                 return MapToKeyCodeModifiers (keyInfo.Modifiers & ~ConsoleModifiers.Shift, (KeyCode)keyInfo.KeyChar);
         }
 
+        // Handle control keys whose VK codes match the related ASCII value (those below ASCII 33) like ESC
+        if (keyInfo.Key != ConsoleKey.None && Enum.IsDefined (typeof (KeyCode), (uint)keyInfo.Key))
+        {
+            if (keyInfo.Modifiers.HasFlag(ConsoleModifiers.Control) && keyInfo.Key == ConsoleKey.I)
+            {
+                return KeyCode.Tab;
+            }
+
+            if (keyInfo.Key == ConsoleKey.Tab)
+            {
+                return MapToKeyCodeModifiers (keyInfo.Modifiers, (KeyCode)((uint)keyInfo.Key));
+            }
+        }
+
+        // Handle control keys (e.g. CursorUp)
+        if (keyInfo.Key != ConsoleKey.None
+            && Enum.IsDefined (typeof (KeyCode), (uint)keyInfo.Key + (uint)KeyCode.MaxCodePoint))
+        {
+            return MapToKeyCodeModifiers (keyInfo.Modifiers, (KeyCode)((uint)keyInfo.Key + (uint)KeyCode.MaxCodePoint));
+        }
+
         if (((ConsoleKey)keyInfo.KeyChar) is >= ConsoleKey.A and <= ConsoleKey.Z)
         {
             // Shifted
@@ -1626,20 +1647,8 @@ internal class NetDriver : ConsoleDriver
             return (KeyCode)keyInfo.Key;
         }
 
-        // Handle control keys whose VK codes match the related ASCII value (those below ASCII 33) like ESC
-        if (keyInfo.Key != ConsoleKey.None && Enum.IsDefined (typeof (KeyCode), (uint)keyInfo.Key))
-        {
-            return MapToKeyCodeModifiers (keyInfo.Modifiers, (KeyCode)keyInfo.Key);
-        }
-
-        // Handle control keys (e.g. CursorUp)
-        if (keyInfo.Key != ConsoleKey.None
-            && Enum.IsDefined (typeof (KeyCode), (uint)keyInfo.Key + (uint)KeyCode.MaxCodePoint))
-        {
-            return MapToKeyCodeModifiers (keyInfo.Modifiers, (KeyCode)((uint)keyInfo.Key + (uint)KeyCode.MaxCodePoint));
-        }
 
-        return (KeyCode)keyInfo.KeyChar;
+        return MapToKeyCodeModifiers (keyInfo.Modifiers, (KeyCode)((uint)keyInfo.Key));
     }
 
     #endregion Keyboard Handling

+ 2 - 2
UICatalog/UICatalog.cs

@@ -897,7 +897,7 @@ internal class UICatalogApp
 
             miIsMenuBorderDisabled.Shortcut =
                 (KeyCode)new Key (miIsMenuBorderDisabled!.Title!.Substring (14, 1) [0]).WithAlt
-                                                                                       .WithCtrl;
+                                                                                       .WithCtrl.NoShift;
             miIsMenuBorderDisabled.CheckType |= MenuItemCheckStyle.Checked;
 
             miIsMenuBorderDisabled.Action += () =>
@@ -919,7 +919,7 @@ internal class UICatalogApp
             miIsMouseDisabled = new () { Title = "_Disable Mouse" };
 
             miIsMouseDisabled.Shortcut =
-                (KeyCode)new Key (miIsMouseDisabled!.Title!.Substring (1, 1) [0]).WithAlt.WithCtrl;
+                (KeyCode)new Key (miIsMouseDisabled!.Title!.Substring (1, 1) [0]).WithAlt.WithCtrl.NoShift;
             miIsMouseDisabled.CheckType |= MenuItemCheckStyle.Checked;
 
             miIsMouseDisabled.Action += () =>