Skip to content

Commit

Permalink
Merge pull request #22 from tofudd/scroll-panel-settings
Browse files Browse the repository at this point in the history
 Optional change of VerticalScrollPanel scrolling keys
  • Loading branch information
TomaszRewak authored Apr 12, 2021
2 parents 1236f1e + ba65351 commit 568364e
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions ConsoleGUI/Controls/VerticalScrollPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
using ConsoleGUI.Space;
using ConsoleGUI.Utils;
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleGUI.Controls
{
Expand Down Expand Up @@ -56,6 +54,9 @@ public Character ScrollBarBackground
.Then(RedrawScrollBar);
}

public ConsoleKey ScrollUpKey { get; set; } = ConsoleKey.UpArrow;
public ConsoleKey ScrollDownKey { get; set; } = ConsoleKey.DownArrow;

public override Cell this[Position position]
{
get
Expand Down Expand Up @@ -105,19 +106,16 @@ void IDrawingContextListener.OnUpdate(DrawingContext drawingContext, Rect rect)

void IInputListener.OnInput(InputEvent inputEvent)
{
switch (inputEvent.Key.Key)
if (inputEvent.Key.Key == ScrollUpKey)
{
case ConsoleKey.UpArrow:
Top -= 1;
return;
case ConsoleKey.DownArrow:
Top += 1;
break;
default:
return;
Top -= 1;
inputEvent.Handled = true;
}
else if (inputEvent.Key.Key == ScrollDownKey)
{
Top += 1;
inputEvent.Handled = true;
}

inputEvent.Handled = true;
}
}
}
}

0 comments on commit 568364e

Please sign in to comment.