|
@@ -172,8 +172,15 @@ namespace Terminal.Gui {
|
|
|
public int SelectedColumn {
|
|
|
get => selectedColumn;
|
|
|
|
|
|
- //try to prevent this being set to an out of bounds column
|
|
|
- set => selectedColumn = Table == null ? 0 : Math.Min (Table.Columns.Count - 1, Math.Max (0, value));
|
|
|
+ set {
|
|
|
+ var oldValue = selectedColumn;
|
|
|
+
|
|
|
+ //try to prevent this being set to an out of bounds column
|
|
|
+ selectedColumn = Table == null ? 0 : Math.Min (Table.Columns.Count - 1, Math.Max (0, value));
|
|
|
+
|
|
|
+ if(oldValue != selectedColumn)
|
|
|
+ OnSelectedCellChanged();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -181,7 +188,15 @@ namespace Terminal.Gui {
|
|
|
/// </summary>
|
|
|
public int SelectedRow {
|
|
|
get => selectedRow;
|
|
|
- set => selectedRow = Table == null ? 0 : Math.Min (Table.Rows.Count - 1, Math.Max (0, value));
|
|
|
+ set {
|
|
|
+
|
|
|
+ var oldValue = selectedColumn;
|
|
|
+
|
|
|
+ selectedRow = Table == null ? 0 : Math.Min (Table.Rows.Count - 1, Math.Max (0, value));
|
|
|
+
|
|
|
+ if(oldValue != selectedRow)
|
|
|
+ OnSelectedCellChanged();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -199,6 +214,11 @@ namespace Terminal.Gui {
|
|
|
/// </summary>
|
|
|
public char SeparatorSymbol { get; set; } = ' ';
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// This event is raised when the selected cell in the table changes.
|
|
|
+ /// </summary>
|
|
|
+ public event Action<EventArgs> SelectedCellChanged;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Initialzies a <see cref="TableView"/> class using <see cref="LayoutStyle.Computed"/> layout.
|
|
|
/// </summary>
|
|
@@ -692,6 +712,14 @@ namespace Terminal.Gui {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Invokes the <see cref="SelectedCellChanged"/> event
|
|
|
+ /// </summary>
|
|
|
+ protected virtual void OnSelectedCellChanged()
|
|
|
+ {
|
|
|
+ SelectedCellChanged?.Invoke(new EventArgs());
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Calculates which columns should be rendered given the <paramref name="bounds"/> in which to display and the <see cref="ColumnOffset"/>
|
|
|
/// </summary>
|