-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTableViewExtensions.cs
More file actions
45 lines (41 loc) · 1.8 KB
/
Copy pathTableViewExtensions.cs
File metadata and controls
45 lines (41 loc) · 1.8 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
38
39
40
41
42
43
44
45
using Terminal.Gui.Views;
namespace TerminalGui.Extensions.Extensions.ViewExtensions;
/// <summary>
/// Extension methods for <see cref="TableView" />.
/// </summary>
public static class TableViewExtensions
{
extension(TableView tableView)
{
/// <summary>
/// Subscribes to the <see cref="TableView.CellActivated" /> event.
/// </summary>
/// <param name="callback">The callback to invoke with the <see cref="CellActivatedEventArgs" />.</param>
/// <returns>The <see cref="TableView" /> instance.</returns>
public TableView OnCellActivated(Action<CellActivatedEventArgs> callback)
{
tableView.CellActivated += (_, e) => callback(e);
return tableView;
}
/// <summary>
/// Subscribes to the <see cref="TableView.CellToggled" /> event.
/// </summary>
/// <param name="callback">The callback to invoke with the <see cref="CellToggledEventArgs" />.</param>
/// <returns>The <see cref="TableView" /> instance.</returns>
public TableView OnCellToggled(Action<CellToggledEventArgs> callback)
{
tableView.CellToggled += (_, e) => callback(e);
return tableView;
}
/// <summary>
/// Subscribes to the <see cref="TableView.SelectedCellChanged" /> event.
/// </summary>
/// <param name="callback">The callback to invoke with the <see cref="SelectedCellChangedEventArgs" />.</param>
/// <returns>The <see cref="TableView" /> instance.</returns>
public TableView OnSelectedCellChanged(Action<SelectedCellChangedEventArgs> callback)
{
tableView.SelectedCellChanged += (_, e) => callback(e);
return tableView;
}
}
}