-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShortcutExtensions.cs
More file actions
37 lines (34 loc) · 1.54 KB
/
Copy pathShortcutExtensions.cs
File metadata and controls
37 lines (34 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using Terminal.Gui.App;
using Terminal.Gui.ViewBase;
using Terminal.Gui.Views;
namespace TerminalGui.Extensions.Extensions.ViewExtensions;
/// <summary>
/// Extension methods for <see cref="Shortcut" />.
/// </summary>
public static class ShortcutExtensions
{
extension(Shortcut shortcut)
{
/// <summary>
/// Subscribes to the <see cref="Shortcut.OrientationChanged" /> event.
/// </summary>
/// <param name="callback">The callback to invoke with the <see cref="EventArgs{T}" /> containing the new <see cref="Orientation" />.</param>
/// <returns>The <see cref="Shortcut" /> instance.</returns>
public Shortcut OnOrientationChanged(Action<EventArgs<Orientation>> callback)
{
shortcut.OrientationChanged += (_, e) => callback(e);
return shortcut;
}
/// <summary>
/// Subscribes to the <see cref="Shortcut.OrientationChanging" /> event.
/// Set <see cref="CancelEventArgs{T}.Cancel" /> to <see langword="true" /> to cancel the change.
/// </summary>
/// <param name="callback">The callback to invoke with the <see cref="CancelEventArgs{T}" /> containing the proposed <see cref="Orientation" />.</param>
/// <returns>The <see cref="Shortcut" /> instance.</returns>
public Shortcut OnOrientationChanging(Action<CancelEventArgs<Orientation>> callback)
{
shortcut.OrientationChanging += (_, e) => callback(e);
return shortcut;
}
}
}