diff --git a/Terminal.Gui/View/View.Command.cs b/Terminal.Gui/View/View.Command.cs
index cfdae3ce6..79ef02bfe 100644
--- a/Terminal.Gui/View/View.Command.cs
+++ b/Terminal.Gui/View/View.Command.cs
@@ -19,9 +19,14 @@ public partial class View // Command APIs
AddCommand (Command.HotKey,
() =>
{
+ if (RaiseHotKeyHandled () is true)
+ {
+ return true;
+ }
+
SetFocus ();
- return RaiseHotKeyHandled ();
+ return true;
});
// Space or single-click - Raise Selected
diff --git a/Terminal.Gui/Views/Label.cs b/Terminal.Gui/Views/Label.cs
index 0294111ab..81de49753 100644
--- a/Terminal.Gui/Views/Label.cs
+++ b/Terminal.Gui/Views/Label.cs
@@ -19,7 +19,7 @@
/// ."
///
///
-public class Label : View
+public class Label : View, IDesignable
{
///
public Label ()
@@ -65,18 +65,32 @@ public class Label : View
private bool? InvokeHotKeyOnNext (CommandContext context)
{
+ if (RaiseHotKeyHandled () == true)
+ {
+ return true;
+ }
+
if (CanFocus)
{
- return SetFocus ();
+ SetFocus ();
+
+ return true;
}
int me = SuperView?.Subviews.IndexOf (this) ?? -1;
if (me != -1 && me < SuperView?.Subviews.Count - 1)
{
- SuperView?.Subviews [me + 1].InvokeCommand (Command.HotKey, context.Key, context.KeyBinding);
+ return SuperView?.Subviews [me + 1].InvokeCommand (Command.HotKey, context.Key, context.KeyBinding) == true;
}
+ return false;
+ }
+
+ ///
+ bool IDesignable.EnableForDesign ()
+ {
+ Text = "_Label";
return true;
}
}
diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs
index 5ed8d642b..a1de6f06a 100644
--- a/Terminal.Gui/Views/ListView.cs
+++ b/Terminal.Gui/Views/ListView.cs
@@ -140,7 +140,12 @@ public class ListView : View, IDesignable
// Accept (Enter key) - Raise Accept event - DO NOT advance state
AddCommand (Command.Accept, () =>
{
- if (OnOpenSelectedItem () && RaiseAccepted () == true)
+ if (RaiseAccepted () == true)
+ {
+ return true;
+ }
+
+ if (OnOpenSelectedItem ())
{
return true;
}
@@ -153,7 +158,12 @@ public class ListView : View, IDesignable
{
if (_allowsMarking)
{
- if (MarkUnmarkSelectedItem () && RaiseSelected () == true)
+ if (RaiseSelected () == true)
+ {
+ return true;
+ }
+
+ if (MarkUnmarkSelectedItem ())
{
return true;
}
diff --git a/Terminal.Gui/Views/Menu/MenuBar.cs b/Terminal.Gui/Views/Menu/MenuBar.cs
index 237bcce48..1825ba594 100644
--- a/Terminal.Gui/Views/Menu/MenuBar.cs
+++ b/Terminal.Gui/Views/Menu/MenuBar.cs
@@ -121,9 +121,12 @@ public class MenuBar : View, IDesignable
Command.Accept,
() =>
{
- ProcessMenu (_selected, Menus [_selected]);
+ if (Menus.Length > 0)
+ {
+ ProcessMenu (_selected, Menus [_selected]);
+ }
- return true;
+ return RaiseAccepted ();
}
);
AddCommand (Command.Toggle, ctx =>
@@ -134,7 +137,7 @@ public class MenuBar : View, IDesignable
});
AddCommand (Command.Select, ctx =>
{
- var res = Run ((ctx.KeyBinding?.Context as MenuItem)?.Action!);
+ var res = Run ((ctx.KeyBinding?.Context as MenuItem)?.Action!);
CloseAllMenus ();
return res;
@@ -1153,11 +1156,11 @@ public class MenuBar : View, IDesignable
SetNeedsDisplay ();
}
- private void ProcessMenu (int i, MenuBarItem mi)
+ private bool ProcessMenu (int i, MenuBarItem mi)
{
if (_selected < 0 && IsMenuOpen)
{
- return;
+ return false;
}
if (mi.IsTopLevel)
@@ -1180,16 +1183,18 @@ public class MenuBar : View, IDesignable
)
&& !CloseMenu ())
{
- return;
+ return true;
}
if (!OpenCurrentMenu.CheckSubMenu ())
{
- return;
+ return true;
}
}
SetNeedsDisplay ();
+
+ return true;
}
private void RemoveSubMenu (int index, bool ignoreUseSubMenusSingleFrame = false)
diff --git a/Terminal.Gui/Views/RadioGroup.cs b/Terminal.Gui/Views/RadioGroup.cs
index 47673ad30..34dca89e8 100644
--- a/Terminal.Gui/Views/RadioGroup.cs
+++ b/Terminal.Gui/Views/RadioGroup.cs
@@ -50,7 +50,7 @@ public class RadioGroup : View, IDesignable, IOrientation
});
// Accept (Enter key) - Raise Accept event - DO NOT advance state
- AddCommand (Command.Accept, () => RaiseAccepted());
+ AddCommand (Command.Accept, () => RaiseAccepted ());
// Hotkey - ctx may indicate a radio item hotkey was pressed. Beahvior depends on HasFocus
// If HasFocus and it's this.HotKey invoke Select command - DO NOT raise Accept
@@ -100,6 +100,11 @@ public class RadioGroup : View, IDesignable, IOrientation
return false;
}
+ if (RaiseHotKeyHandled () == true)
+ {
+ return true;
+ };
+
// Default Command.Hotkey sets focus
SetFocus ();
diff --git a/UnitTests/TestHelpers.cs b/UnitTests/TestHelpers.cs
index d13924150..976fc058a 100644
--- a/UnitTests/TestHelpers.cs
+++ b/UnitTests/TestHelpers.cs
@@ -742,7 +742,7 @@ public class TestsAllViews
public static IEnumerable