Skip to content

Commit

Permalink
Merge pull request #448 from tig/refactor_keyboard_events
Browse files Browse the repository at this point in the history
Refactored keydown/up/press events to use event vs. Action<T>
  • Loading branch information
tig authored May 21, 2020
2 parents 746f18e + 511447c commit 4c959b9
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 661 deletions.
14 changes: 7 additions & 7 deletions Example/demo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ static void ShowTextAlignments ()
Width = Dim.Fill (),
Height = Dim.Fill ()
};
container.OnKeyUp += (KeyEvent ke) => {
if (ke.Key == Key.Esc)
container.KeyUp += (sender, e) => {
if (e.KeyEvent.Key == Key.Esc)
container.Running = false;
};

Expand Down Expand Up @@ -413,11 +413,11 @@ static void ListSelectionDemo (bool multiple)
#endregion


#region OnKeyDown / OnKeyPress / OnKeyUp Demo
#region KeyDown / KeyPress / KeyUp Demo
private static void OnKeyDownPressUpDemo ()
{
var container = new Dialog (
"OnKeyDown & OnKeyPress & OnKeyUp demo", 80, 20,
"KeyDown & KeyPress & KeyUp demo", 80, 20,
new Button ("Close") { Clicked = () => { Application.RequestStop (); } }) {
Width = Dim.Fill (),
Height = Dim.Fill (),
Expand Down Expand Up @@ -469,9 +469,9 @@ void KeyDownPressUp (KeyEvent keyEvent, string updown)
}


container.OnKeyDown += (KeyEvent keyEvent) => KeyDownPressUp (keyEvent, "Down");
container.OnKeyPress += (KeyEvent keyEvent) => KeyDownPressUp (keyEvent, "Press");
container.OnKeyUp += (KeyEvent keyEvent) => KeyDownPressUp (keyEvent, "Up");
container.KeyDown += (o, e) => KeyDownPressUp (e.KeyEvent, "Down");
container.KeyPress += (o, e) => KeyDownPressUp (e.KeyEvent, "Press");
container.KeyUp += (o, e) => KeyDownPressUp (e.KeyEvent, "Up");
Application.Run (container);
}
#endregion
Expand Down
Loading

0 comments on commit 4c959b9

Please sign in to comment.