diff --git a/Terminal.Gui/View/Adornment/Adornment.cs b/Terminal.Gui/View/Adornment/Adornment.cs
index 5a99d7a30..307f3cb3e 100644
--- a/Terminal.Gui/View/Adornment/Adornment.cs
+++ b/Terminal.Gui/View/Adornment/Adornment.cs
@@ -212,7 +212,7 @@ public class Adornment : View
}
///
- protected internal override bool OnMouseEnter (MouseEvent mouseEvent)
+ protected internal override bool? OnMouseEnter (MouseEvent mouseEvent)
{
// Invert Normal
if (Diagnostics.HasFlag (ViewDiagnosticFlags.MouseEnter) && ColorScheme != null)
diff --git a/Terminal.Gui/View/Adornment/Border.cs b/Terminal.Gui/View/Adornment/Border.cs
index a45c3f7d2..a67de3edd 100644
--- a/Terminal.Gui/View/Adornment/Border.cs
+++ b/Terminal.Gui/View/Adornment/Border.cs
@@ -57,7 +57,7 @@ public class Border : Adornment
Application.GrabbingMouse += Application_GrabbingMouse;
Application.UnGrabbingMouse += Application_UnGrabbingMouse;
- HighlightStyle = HighlightStyle.Pressed;
+ HighlightStyle |= HighlightStyle.Pressed;
Highlight += Border_Highlight;
}
@@ -73,6 +73,12 @@ public class Border : Adornment
///
public override void BeginInit ()
{
+ // TOOD: Hack - make Arragnement overidable
+ if ((Parent?.Arrangement & ViewArrangement.Movable) != 0)
+ {
+ HighlightStyle |= HighlightStyle.Hover;
+ }
+
base.BeginInit ();
#if SUBVIEW_BASED_BORDER
@@ -100,7 +106,7 @@ public class Border : Adornment
LayoutStarted += OnLayoutStarted;
}
#endif
-}
+ }
#if SUBVIEW_BASED_BORDER
private void OnLayoutStarted (object sender, LayoutEventArgs e)
@@ -190,18 +196,30 @@ public class Border : Adornment
#region Mouse Support
- private LineStyle _savedHighlightLineStyle;
+ private LineStyle? _savedHighlightLineStyle;
private void Border_Highlight (object sender, HighlightEventArgs e)
{
- if (e.HighlightStyle == HighlightStyle)
+ if (e.HighlightStyle.HasFlag (HighlightStyle.Pressed))
{
- _savedHighlightLineStyle = Parent?.BorderStyle ?? LineStyle;
+ if (!_savedHighlightLineStyle.HasValue)
+ {
+ _savedHighlightLineStyle = Parent?.BorderStyle ?? LineStyle;
+ }
LineStyle = LineStyle.Heavy;
}
- else
+ else if (e.HighlightStyle.HasFlag (HighlightStyle.Hover))
{
- LineStyle = _savedHighlightLineStyle;
+ if (!_savedHighlightLineStyle.HasValue)
+ {
+ _savedHighlightLineStyle = Parent?.BorderStyle ?? LineStyle;
+ }
+ LineStyle = LineStyle.Double;
+ }
+
+ if (e.HighlightStyle == HighlightStyle.None && _savedHighlightLineStyle.HasValue)
+ {
+ LineStyle = _savedHighlightLineStyle.Value;
}
Parent?.SetNeedsDisplay ();
e.Cancel = true;
@@ -321,7 +339,7 @@ public class Border : Adornment
}
}
-#endregion Mouse Support
+ #endregion Mouse Support
///
public override void OnDrawContent (Rectangle contentArea)
diff --git a/Terminal.Gui/View/ViewMouse.cs b/Terminal.Gui/View/ViewMouse.cs
index 4b7e4f146..ec0f99942 100644
--- a/Terminal.Gui/View/ViewMouse.cs
+++ b/Terminal.Gui/View/ViewMouse.cs
@@ -90,7 +90,17 @@ public partial class View
return false;
}
- return OnMouseEnter (mouseEvent);
+ if (OnMouseEnter (mouseEvent) == true)
+ {
+ return true;
+ }
+
+ if (HighlightStyle.HasFlag(HighlightStyle.Hover))
+ {
+ SetHighlight (HighlightStyle.Hover);
+ }
+
+ return false;
}
///
@@ -108,7 +118,7 @@ public partial class View
///
///
/// , if the event was handled, otherwise.
- protected internal virtual bool OnMouseEnter (MouseEvent mouseEvent)
+ protected internal virtual bool? OnMouseEnter (MouseEvent mouseEvent)
{
var args = new MouseEventEventArgs (mouseEvent);
@@ -150,7 +160,17 @@ public partial class View
return false;
}
- return OnMouseLeave (mouseEvent);
+ if (OnMouseEnter (mouseEvent) == true)
+ {
+ return true;
+ }
+
+ if (HighlightStyle.HasFlag (HighlightStyle.Hover))
+ {
+ SetHighlight (HighlightStyle.None);
+ }
+
+ return false;
}
///
/// Called by when a mouse leaves . The view will
@@ -400,12 +420,28 @@ public partial class View
///
internal void SetHighlight (HighlightStyle style)
{
+ // TODO: Make the highlight colors configurable
+
// Enable override via virtual method and/or event
if (OnHighlight (style) == true)
{
return;
}
+ if (style.HasFlag (HighlightStyle.Hover))
+ {
+ if (_savedHighlightColorScheme is null && ColorScheme is { })
+ {
+ _savedHighlightColorScheme ??= ColorScheme;
+
+ var cs = new ColorScheme (ColorScheme)
+ {
+ Normal = new (ColorName.BrightRed, ColorName.Black),
+ };
+ ColorScheme = cs;
+ }
+ }
+
if (style.HasFlag (HighlightStyle.Pressed) || style.HasFlag (HighlightStyle.PressedOutside))
{
@@ -415,14 +451,9 @@ public partial class View
if (CanFocus)
{
- // TODO: Make the inverted color configurable
var cs = new ColorScheme (ColorScheme)
{
- // For Buttons etc...
Focus = new (ColorScheme.Normal.Foreground, ColorScheme.Focus.Background),
-
- // For Adornments
- Normal = new (ColorScheme.Focus.Foreground, ColorScheme.Normal.Background)
};
ColorScheme = cs;
}
@@ -437,7 +468,8 @@ public partial class View
}
}
}
- else
+
+ if (style == HighlightStyle.None)
{
// Unhighlight
if (_savedHighlightColorScheme is { })
diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs
index cfeed6625..f77063934 100644
--- a/Terminal.Gui/Views/Button.cs
+++ b/Terminal.Gui/Views/Button.cs
@@ -54,6 +54,7 @@ public class Button : View
CanFocus = true;
AutoSize = true;
HighlightStyle |= HighlightStyle.Pressed;
+ HighlightStyle |= HighlightStyle.Hover;
// Override default behavior of View
AddCommand (Command.HotKey, () =>