瀏覽代碼

Add mouse wheel.

BDisp 1 年之前
父節點
當前提交
86e0db278c
共有 1 個文件被更改,包括 20 次插入0 次删除
  1. 20 0
      Terminal.Gui/Views/Scroll.cs

+ 20 - 0
Terminal.Gui/Views/Scroll.cs

@@ -237,6 +237,16 @@ public class Scroll : View
         {
             Position = Math.Min (Position + barSize, Size - barSize);
         }
+        else if ((me.Flags == MouseFlags.WheeledDown && Orientation == Orientation.Vertical)
+                 || (me.Flags == MouseFlags.WheeledRight && Orientation == Orientation.Horizontal))
+        {
+            Position = Math.Min (Position + 1, Size - barSize);
+        }
+        else if ((me.Flags == MouseFlags.WheeledUp && Orientation == Orientation.Vertical)
+                 || (me.Flags == MouseFlags.WheeledLeft && Orientation == Orientation.Horizontal))
+        {
+            Position = Math.Max (Position - 1, 0);
+        }
     }
 
     private void Scroll_Removed (object sender, SuperViewChangedEventArgs e)
@@ -350,6 +360,16 @@ public class Scroll : View
                 Application.UngrabMouse ();
             }
         }
+        else if ((me.Flags == MouseFlags.WheeledDown && Orientation == Orientation.Vertical)
+                 || (me.Flags == MouseFlags.WheeledRight && Orientation == Orientation.Horizontal))
+        {
+            Position = Math.Min (Position + 1, Size - barSize);
+        }
+        else if ((me.Flags == MouseFlags.WheeledUp && Orientation == Orientation.Vertical)
+                 || (me.Flags == MouseFlags.WheeledLeft && Orientation == Orientation.Horizontal))
+        {
+            Position = Math.Max (Position - 1, 0);
+        }
         else
         {
             return;