mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-29 17:28:01 +01:00
Add wheel feature.
This commit is contained in:
@@ -65,20 +65,20 @@ internal class TabRowView : View
|
||||
SetFocus ();
|
||||
}
|
||||
|
||||
if (!me.IsSingleDoubleOrTripleClicked)
|
||||
if (me is { IsSingleDoubleOrTripleClicked: false, IsWheel: false })
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (me.IsSingleDoubleOrTripleClicked)
|
||||
if (me.IsSingleDoubleOrTripleClicked || me.IsWheel)
|
||||
{
|
||||
var scrollIndicatorHit = 0;
|
||||
|
||||
if (me.View is { Id: "rightScrollIndicator" })
|
||||
if (me.View is { Id: "rightScrollIndicator" } || me.Flags.HasFlag (MouseFlags.WheeledDown) || me.Flags.HasFlag (MouseFlags.WheeledRight))
|
||||
{
|
||||
scrollIndicatorHit = 1;
|
||||
}
|
||||
else if (me.View is { Id: "leftScrollIndicator" })
|
||||
else if (me.View is { Id: "leftScrollIndicator" } || me.Flags.HasFlag (MouseFlags.WheeledUp) || me.Flags.HasFlag (MouseFlags.WheeledLeft))
|
||||
{
|
||||
scrollIndicatorHit = -1;
|
||||
}
|
||||
|
||||
@@ -1490,6 +1490,35 @@ public class TabViewTests (ITestOutputHelper output)
|
||||
top.Dispose ();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[SetupFakeDriver]
|
||||
public void Mouse_Wheel_Changes_Tab ()
|
||||
{
|
||||
TabView tv = GetTabView (out Tab tab1, out Tab tab2);
|
||||
|
||||
tv.Width = 20;
|
||||
tv.Height = 5;
|
||||
|
||||
Toplevel top = new ();
|
||||
top.Add (tv);
|
||||
Application.Begin (top);
|
||||
|
||||
Assert.False (tab1.HasFocus);
|
||||
|
||||
Application.RaiseMouseEvent (new () { Position = new (1, 1), Flags = MouseFlags.WheeledDown });
|
||||
Assert.True (tab2.HasFocus);
|
||||
|
||||
Application.RaiseMouseEvent (new () { Position = new (1, 1), Flags = MouseFlags.WheeledUp });
|
||||
Assert.True (tab1.HasFocus);
|
||||
|
||||
Application.RaiseMouseEvent (new () { Position = new (1, 1), Flags = MouseFlags.WheeledRight });
|
||||
Assert.True (tab2.HasFocus);
|
||||
|
||||
Application.RaiseMouseEvent (new () { Position = new (1, 1), Flags = MouseFlags.WheeledLeft });
|
||||
Assert.True (tab1.HasFocus);
|
||||
top.Dispose ();
|
||||
}
|
||||
|
||||
private TabView GetTabView () { return GetTabView (out _, out _); }
|
||||
|
||||
private TabView GetTabView (out Tab tab1, out Tab tab2, bool initFakeDriver = true)
|
||||
|
||||
Reference in New Issue
Block a user