浏览代码

make keybindings share base

tznind 7 月之前
父节点
当前提交
c18cff280e
共有 2 个文件被更改,包括 3 次插入3 次删除
  1. 2 2
      Terminal.Gui/Input/Keyboard/KeyBindings.cs
  2. 1 1
      Terminal.Gui/Input/Mouse/MouseBindings.cs

+ 2 - 2
Terminal.Gui/Input/Keyboard/KeyBindings.cs

@@ -7,10 +7,10 @@ namespace Terminal.Gui;
 /// <seealso cref="Application.KeyBindings"/>
 /// <seealso cref="View.KeyBindings"/>
 /// <seealso cref="Command"/>
-public class KeyBindings
+public class KeyBindings : Bindings<Key,KeyBinding>
 {
     /// <summary>Initializes a new instance bound to <paramref name="target"/>.</summary>
-    public KeyBindings (View? target) { Target = target; }
+    public KeyBindings (View? target) :base((commands,key)=> new KeyBinding (commands)) { Target = target; }
 
     /// <summary>Adds a <see cref="KeyBinding"/> to the collection.</summary>
     /// <param name="key"></param>

+ 1 - 1
Terminal.Gui/Input/Mouse/MouseBindings.cs

@@ -3,7 +3,7 @@ using System.Collections.Generic;
 
 namespace Terminal.Gui;
 
-public abstract class Bindings<TKey, TBind> where TKey: Enum where TBind : IInputBinding, new()
+public abstract class Bindings<TKey, TBind>  where TBind : IInputBinding, new()
 {
     protected readonly Dictionary<TKey, TBind> _bindings = new ();
     private readonly Func<Command [], TKey, TBind> _constructBinding;