Browse Source

Add mouse wheel.

BDisp 1 year ago
parent
commit
86e0db278c
1 changed files with 20 additions and 0 deletions
  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);
             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)
     private void Scroll_Removed (object sender, SuperViewChangedEventArgs e)
@@ -350,6 +360,16 @@ public class Scroll : View
                 Application.UngrabMouse ();
                 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
         else
         {
         {
             return;
             return;