diff --git a/Terminal.Gui/View/View.Command.cs b/Terminal.Gui/View/View.Command.cs
index a75f368cd..7ec42a747 100644
--- a/Terminal.Gui/View/View.Command.cs
+++ b/Terminal.Gui/View/View.Command.cs
@@ -68,9 +68,9 @@ public partial class View // Command APIs
/// If the event was canceled. If the event was raised but not canceled.
/// If no event was raised.
///
- protected bool? RaiseAccepting ()
+ protected bool? RaiseAccepting (CommandContext ctx)
{
- CommandEventArgs args = new ();
+ CommandEventArgs args = new () { Context = ctx };
// Best practice is to invoke the virtual method first.
// This allows derived classes to handle the event and potentially cancel it.
diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs
index c10e29545..e29043ed9 100644
--- a/Terminal.Gui/Views/Button.cs
+++ b/Terminal.Gui/Views/Button.cs
@@ -79,7 +79,7 @@ public class Button : View, IDesignable
return true;
}
- bool? handled = RaiseAccepting ();
+ bool? handled = RaiseAccepting (ctx);
if (handled == true)
{
@@ -132,6 +132,7 @@ public class Button : View, IDesignable
return;
}
+ // TODO: With https://github.com/gui-cs/Terminal.Gui/issues/3778 we won't have to pass data:
e.Handled = InvokeCommand (Command.HotKey, new (Command.HotKey, null, data: this)) == true;
}
diff --git a/Terminal.Gui/Views/ComboBox.cs b/Terminal.Gui/Views/ComboBox.cs
index 746dc7d98..3f92174c8 100644
--- a/Terminal.Gui/Views/ComboBox.cs
+++ b/Terminal.Gui/Views/ComboBox.cs
@@ -84,7 +84,7 @@ public class ComboBox : View, IDesignable
{
return null;
}
- return ActivateSelected ();
+ return ActivateSelected (ctx);
});
AddCommand (Command.Toggle, () => ExpandCollapse ());
AddCommand (Command.Expand, () => Expand ());
@@ -392,7 +392,7 @@ public class ComboBox : View, IDesignable
}
}
- private bool ActivateSelected ()
+ private bool ActivateSelected (CommandContext ctx)
{
if (HasItems ())
{
@@ -401,7 +401,7 @@ public class ComboBox : View, IDesignable
return false;
}
- return RaiseAccepting () == true;
+ return RaiseAccepting (ctx) == true;
}
return false;
diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs
index 382fdbf87..0c54aa261 100644
--- a/Terminal.Gui/Views/ListView.cs
+++ b/Terminal.Gui/Views/ListView.cs
@@ -138,9 +138,9 @@ public class ListView : View, IDesignable
AddCommand (Command.ScrollRight, () => ScrollHorizontal (1));
// Accept (Enter key) - Raise Accept event - DO NOT advance state
- AddCommand (Command.Accept, () =>
+ AddCommand (Command.Accept, (ctx) =>
{
- if (RaiseAccepting () == true)
+ if (RaiseAccepting (ctx) == true)
{
return true;
}
diff --git a/Terminal.Gui/Views/Menu/MenuBar.cs b/Terminal.Gui/Views/Menu/MenuBar.cs
index 957e568cf..731edc11c 100644
--- a/Terminal.Gui/Views/Menu/MenuBar.cs
+++ b/Terminal.Gui/Views/Menu/MenuBar.cs
@@ -119,14 +119,14 @@ public class MenuBar : View, IDesignable
AddCommand (
Command.Accept,
- () =>
+ (ctx) =>
{
if (Menus.Length > 0)
{
ProcessMenu (_selected, Menus [_selected]);
}
- return RaiseAccepting ();
+ return RaiseAccepting (ctx);
}
);
AddCommand (Command.Toggle, ctx =>
diff --git a/Terminal.Gui/Views/MessageBox.cs b/Terminal.Gui/Views/MessageBox.cs
index af35b257e..76da412b1 100644
--- a/Terminal.Gui/Views/MessageBox.cs
+++ b/Terminal.Gui/Views/MessageBox.cs
@@ -338,6 +338,7 @@ public static class MessageBox
// Create button array for Dialog
var count = 0;
List