diff --git a/Terminal.Gui/View/Adornment/Adornment.cs b/Terminal.Gui/View/Adornment/Adornment.cs
index 5fe40cab9..b6277f326 100644
--- a/Terminal.Gui/View/Adornment/Adornment.cs
+++ b/Terminal.Gui/View/Adornment/Adornment.cs
@@ -244,6 +244,11 @@ public class Adornment : View
/// , if the event was handled, otherwise.
protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
{
+ if (Parent is null)
+ {
+ return false;
+ }
+
var args = new MouseEventEventArgs (mouseEvent);
if (mouseEvent.Flags.HasFlag (MouseFlags.Button1Clicked))
diff --git a/Terminal.Gui/View/Adornment/Padding.cs b/Terminal.Gui/View/Adornment/Padding.cs
index 3c2a645c1..d9d373de4 100644
--- a/Terminal.Gui/View/Adornment/Padding.cs
+++ b/Terminal.Gui/View/Adornment/Padding.cs
@@ -52,13 +52,18 @@ public class Padding : Adornment
/// , if the event was handled, otherwise.
protected internal override bool OnMouseEvent (MouseEvent mouseEvent)
{
+ if (Parent is null)
+ {
+ return false;
+ }
+
if (mouseEvent.Flags.HasFlag (MouseFlags.Button1Clicked))
{
if (Parent.CanFocus && !Parent.HasFocus)
{
Parent.SetFocus ();
Parent.SetNeedsDisplay ();
- return true;
+ return mouseEvent.Handled = true;
}
}
diff --git a/Terminal.Gui/View/ViewMouse.cs b/Terminal.Gui/View/ViewMouse.cs
index 81961441e..e78ede31e 100644
--- a/Terminal.Gui/View/ViewMouse.cs
+++ b/Terminal.Gui/View/ViewMouse.cs
@@ -104,7 +104,8 @@ public partial class View
{
if (!Enabled)
{
- return true;
+ // A disabled view should not eat mouse events
+ return false;
}
if (!CanBeVisible (this))
@@ -150,6 +151,7 @@ public partial class View
{
if (!Enabled)
{
+ // QUESTION: Is this right? Should a disabled view eat mouse clicks?
args.Handled = true;
return true;
}
diff --git a/Terminal.Gui/Views/ScrollView.cs b/Terminal.Gui/Views/ScrollView.cs
index 9bc14c3f8..72ebcb355 100644
--- a/Terminal.Gui/Views/ScrollView.cs
+++ b/Terminal.Gui/Views/ScrollView.cs
@@ -410,6 +410,12 @@ public class ScrollView : View
///
protected internal override bool OnMouseEvent (MouseEvent me)
{
+ if (!Enabled)
+ {
+ // A disabled view should not eat mouse events
+ return false;
+ }
+
if (me.Flags == MouseFlags.WheeledDown && ShowVerticalScrollIndicator)
{
ScrollDown (1);
diff --git a/UICatalog/Scenarios/Buttons.cs b/UICatalog/Scenarios/Buttons.cs
index c03bbbb62..e3c9b5ea2 100644
--- a/UICatalog/Scenarios/Buttons.cs
+++ b/UICatalog/Scenarios/Buttons.cs
@@ -396,7 +396,7 @@ public class Buttons : Scenario
{
X = Pos.Right (label) + 1,
Y = Pos.Top (label),
- Title = $"Accept Count: {acceptCount}",
+ Title = $"Accept Count (press-and-hold): {acceptCount}",
WantContinuousButtonPressed = true,
};
repeatButton.Accept += (s, e) =>
diff --git a/UnitTests/TestHelpers.cs b/UnitTests/TestHelpers.cs
index 83187ebf4..e87450dd4 100644
--- a/UnitTests/TestHelpers.cs
+++ b/UnitTests/TestHelpers.cs
@@ -729,6 +729,87 @@ internal partial class TestHelpers
return view;
}
+ public static List GetAllViewClasses ()
+ {
+ return typeof (View).Assembly.GetTypes ()
+ .Where (
+ myType => myType.IsClass
+ && !myType.IsAbstract
+ && myType.IsPublic
+ && myType.IsSubclassOf (typeof (View))
+ )
+ .ToList ();
+ }
+
+ public static View CreateViewFromType (Type type, ConstructorInfo ctor)
+ {
+ View viewType = null;
+
+ if (type.IsGenericType && type.IsTypeDefinition)
+ {
+ List gTypes = new ();
+
+ foreach (Type args in type.GetGenericArguments ())
+ {
+ gTypes.Add (typeof (object));
+ }
+
+ type = type.MakeGenericType (gTypes.ToArray ());
+
+ Assert.IsType (type, (View)Activator.CreateInstance (type));
+ }
+ else
+ {
+ ParameterInfo [] paramsInfo = ctor.GetParameters ();
+ Type paramType;
+ List