diff --git a/Terminal.Gui/View/View.Attribute.cs b/Terminal.Gui/View/View.Attribute.cs
index 8e9173bfc..759bfceab 100644
--- a/Terminal.Gui/View/View.Attribute.cs
+++ b/Terminal.Gui/View/View.Attribute.cs
@@ -10,7 +10,7 @@ public partial class View
#region ColorScheme
- private ColorScheme? _colorScheme;
+ internal ColorScheme? _colorScheme;
/// The color scheme for this view, if it is not defined, it returns the 's color scheme.
public virtual ColorScheme? ColorScheme
@@ -43,11 +43,21 @@ public partial class View
///
public virtual Attribute GetFocusColor ()
{
+
+ Attribute currAttribute = ColorScheme?.Normal ?? Attribute.Default;
+ Attribute newAttribute = new Attribute ();
+ CancelEventArgs args = new CancelEventArgs (in currAttribute, ref newAttribute);
+ GettingFocusColor?.Invoke (this, args);
+ if (args.Cancel)
+ {
+ return args.NewValue;
+ }
ColorScheme? cs = ColorScheme ?? new ();
return Enabled ? GetColor (cs.Focus) : cs.Disabled;
}
+ public event EventHandler>? GettingFocusColor;
/// Determines the current based on the value.
///
/// if is or
@@ -69,11 +79,25 @@ public partial class View
///
public virtual Attribute GetHotNormalColor ()
{
+ Attribute currAttribute = ColorScheme?.Normal ?? Attribute.Default;
+ Attribute newAttribute = new Attribute ();
+ CancelEventArgs args = new CancelEventArgs (in currAttribute, ref newAttribute);
+ GettingHotNormalColor?.Invoke (this, args);
+
+ if (args.Cancel)
+ {
+ return args.NewValue;
+ }
+
+
ColorScheme? cs = ColorScheme ?? new ();
return Enabled ? GetColor (cs.HotNormal) : cs.Disabled;
}
+ public event EventHandler>? GettingHotNormalColor;
+
+
/// Determines the current based on the value.
///
/// if is or
diff --git a/Terminal.Gui/View/View.Drawing.cs b/Terminal.Gui/View/View.Drawing.cs
index 1a198a03d..db6a6bf36 100644
--- a/Terminal.Gui/View/View.Drawing.cs
+++ b/Terminal.Gui/View/View.Drawing.cs
@@ -673,7 +673,7 @@ public partial class View // Drawing APIs
// Get the entire map
if (p.Value is { })
{
- SetAttribute (p.Value.Value.Attribute ?? ColorScheme!.Normal);
+ SetAttribute (p.Value.Value.Attribute ?? GetNormalColor());
Driver.Move (p.Key.X, p.Key.Y);
// TODO: #2616 - Support combining sequences that don't normalize
diff --git a/Terminal.Gui/View/View.Mouse.cs b/Terminal.Gui/View/View.Mouse.cs
index 7cb77f65b..0967bea27 100644
--- a/Terminal.Gui/View/View.Mouse.cs
+++ b/Terminal.Gui/View/View.Mouse.cs
@@ -1,5 +1,6 @@
#nullable enable
using System.ComponentModel;
+using static Unix.Terminal.Delegates;
namespace Terminal.Gui;
@@ -97,21 +98,35 @@ public partial class View // Mouse APIs
return args.Cancel;
}
- ColorScheme? cs = ColorScheme;
+ ColorScheme? cs = _colorScheme;
- if (cs is null)
- {
- cs = new ();
- }
+ //if (cs is null)
+ //{
+ // cs = new ();
+ //}
_savedNonHoverColorScheme = cs;
- ColorScheme = ColorScheme?.GetHighlightColorScheme ();
+ _colorScheme = GetHighlightColorScheme ();
+ SetNeedsDraw ();
}
return false;
}
+ public ColorScheme GetHighlightColorScheme ()
+ {
+ ColorScheme? cs = _colorScheme ?? SuperView!.ColorScheme;
+
+ return cs with
+ {
+ Normal = new (GetNormalColor().Foreground.GetHighlightColor (), GetNormalColor ().Background),
+ HotNormal = new (GetHotNormalColor ().Foreground.GetHighlightColor (), GetHotNormalColor().Background),
+ Focus = new (GetFocusColor().Foreground.GetHighlightColor (), GetFocusColor().Background),
+ HotFocus = new (GetHotFocusColor().Foreground.GetHighlightColor (), GetHotFocusColor().Background)
+ };
+ }
+
///
/// Called when the mouse moves over the View's and no other non-SubView occludes it.
/// will
@@ -199,10 +214,12 @@ public partial class View // Mouse APIs
var hover = HighlightStyle.None;
RaiseHighlight (new (ref copy, ref hover));
- if (_savedNonHoverColorScheme is { })
+ //if (_savedNonHoverColorScheme is { })
{
- ColorScheme = _savedNonHoverColorScheme;
+ _colorScheme = _savedNonHoverColorScheme;
_savedNonHoverColorScheme = null;
+ SetNeedsDraw ();
+
}
}
}
@@ -715,9 +732,9 @@ public partial class View // Mouse APIs
if (args.NewValue.HasFlag (HighlightStyle.Pressed) || args.NewValue.HasFlag (HighlightStyle.PressedOutside))
{
- if (_savedHighlightColorScheme is null && ColorScheme is { })
+ if (_savedHighlightColorScheme is null && _colorScheme is { })
{
- _savedHighlightColorScheme ??= ColorScheme;
+ _savedHighlightColorScheme = _colorScheme;
if (CanFocus)
{
@@ -726,7 +743,7 @@ public partial class View // Mouse APIs
// Highlight the foreground focus color
Focus = new (ColorScheme.Focus.Foreground.GetHighlightColor (), ColorScheme.Focus.Background.GetHighlightColor ())
};
- ColorScheme = cs;
+ _colorScheme = cs;
}
else
{
@@ -735,7 +752,7 @@ public partial class View // Mouse APIs
// Invert Focus color foreground/background. We can do this because we know the view is not going to be focused.
Normal = new (ColorScheme.Focus.Background, ColorScheme.Normal.Foreground)
};
- ColorScheme = cs;
+ _colorScheme = cs;
}
}
@@ -746,10 +763,11 @@ public partial class View // Mouse APIs
if (args.NewValue == HighlightStyle.None)
{
// Unhighlight
- if (_savedHighlightColorScheme is { })
+ //if (_savedHighlightColorScheme is { })
{
- ColorScheme = _savedHighlightColorScheme;
+ _colorScheme = _savedHighlightColorScheme;
_savedHighlightColorScheme = null;
+ SetNeedsDraw ();
}
}
diff --git a/Terminal.Gui/Views/Bar.cs b/Terminal.Gui/Views/Bar.cs
index b4ba2bef8..a76061083 100644
--- a/Terminal.Gui/Views/Bar.cs
+++ b/Terminal.Gui/Views/Bar.cs
@@ -78,7 +78,7 @@ public class Bar : View, IOrientation, IDesignable
public override void EndInit ()
{
base.EndInit ();
- ColorScheme = Colors.ColorSchemes ["Menu"];
+ //ColorScheme = Colors.ColorSchemes ["Menu"];
}
///
@@ -216,7 +216,7 @@ public class Bar : View, IOrientation, IDesignable
{
View barItem = SubViews.ElementAt (index);
- barItem.ColorScheme = ColorScheme;
+ //barItem.ColorScheme = ColorScheme;
barItem.X = Pos.Align (Alignment.Start, AlignmentModes);
barItem.Y = 0; //Pos.Center ();
@@ -250,7 +250,7 @@ public class Bar : View, IOrientation, IDesignable
View barItem = SubViews.ElementAt (index);
- barItem.ColorScheme = ColorScheme;
+ //barItem.ColorScheme = ColorScheme;
if (!barItem.Visible)
{
diff --git a/Terminal.Gui/Views/CheckBox.cs b/Terminal.Gui/Views/CheckBox.cs
index cec31d4f9..1413ad902 100644
--- a/Terminal.Gui/Views/CheckBox.cs
+++ b/Terminal.Gui/Views/CheckBox.cs
@@ -8,7 +8,7 @@ public class CheckBox : View
/// Gets or sets the default Highlight Style.
///
[SerializableConfigurationProperty (Scope = typeof (ThemeScope))]
- public static HighlightStyle DefaultHighlightStyle { get; set; } = HighlightStyle.PressedOutside | HighlightStyle.Pressed | HighlightStyle.Hover;
+ public static HighlightStyle DefaultHighlightStyle { get; set; } = /*HighlightStyle.PressedOutside | HighlightStyle.Pressed | */HighlightStyle.Hover;
///
/// Initializes a new instance of .
@@ -43,6 +43,13 @@ public class CheckBox : View
HighlightStyle = DefaultHighlightStyle;
}
+ ///
+ public override ColorScheme? ColorScheme
+ {
+ get => base.ColorScheme;
+ set => base.ColorScheme = value;
+ }
+
private bool? AdvanceAndSelect (ICommandContext? commandContext)
{
bool? cancelled = AdvanceCheckState ();
diff --git a/Terminal.Gui/Views/FlagSelector.cs b/Terminal.Gui/Views/FlagSelector.cs
index a07b1c0fe..a0891e4c1 100644
--- a/Terminal.Gui/Views/FlagSelector.cs
+++ b/Terminal.Gui/Views/FlagSelector.cs
@@ -306,7 +306,7 @@ public class FlagSelector : View, IOrientation, IDesignable
Title = nameWithHotKey,
Id = name,
Data = flag,
- // HighlightStyle = HighlightStyle
+ HighlightStyle = HighlightStyle.Hover
};
checkbox.GettingNormalColor += (_, e) =>
@@ -314,10 +314,57 @@ public class FlagSelector : View, IOrientation, IDesignable
if (SuperView is {HasFocus: true})
{
e.Cancel = true;
- e.NewValue = GetFocusColor ();
+
+ if (!HasFocus)
+ {
+ e.NewValue = GetFocusColor ();
+ }
+ else
+ {
+ if (checkbox._colorScheme is { })
+ {
+ e.NewValue = checkbox._colorScheme.Normal;
+ }
+ else
+ {
+ e.NewValue = GetNormalColor ();
+ }
+ }
}
};
+ checkbox.GettingHotNormalColor += (_, e) =>
+ {
+ if (SuperView is { HasFocus: true })
+ {
+ e.Cancel = true;
+ if (!HasFocus)
+ {
+ e.NewValue = GetHotFocusColor ();
+ }
+ else
+ {
+ e.NewValue = GetHotNormalColor ();
+ }
+ }
+ };
+
+ checkbox.GettingFocusColor += (_, e) =>
+ {
+ if (SuperView is { HasFocus: true })
+ {
+ e.Cancel = true;
+ if (!HasFocus)
+ {
+ e.NewValue = GetNormalColor ();
+ }
+ else
+ {
+ e.NewValue = GetFocusColor ();
+ }
+ }
+ };
+
checkbox.Selecting += (sender, args) => { RaiseSelecting (args.Context); };
checkbox.CheckedStateChanged += (sender, args) =>
diff --git a/Terminal.Gui/Views/Menu/Menuv2.cs b/Terminal.Gui/Views/Menu/Menuv2.cs
index a8a0b9574..ca73df803 100644
--- a/Terminal.Gui/Views/Menu/Menuv2.cs
+++ b/Terminal.Gui/Views/Menu/Menuv2.cs
@@ -18,6 +18,7 @@ public class Menuv2 : Bar
Orientation = Orientation.Vertical;
Width = Dim.Auto ();
Height = Dim.Auto (DimAutoStyle.Content, 1);
+ base.ColorScheme = Colors.ColorSchemes ["Menu"];
Border!.Thickness = new Thickness (1, 1, 1, 1);
Border.LineStyle = LineStyle.Single;
diff --git a/Terminal.Gui/Views/Shortcut.cs b/Terminal.Gui/Views/Shortcut.cs
index d32d4f02d..fc48ed2fd 100644
--- a/Terminal.Gui/Views/Shortcut.cs
+++ b/Terminal.Gui/Views/Shortcut.cs
@@ -124,11 +124,11 @@ public class Shortcut : View, IOrientation, IDesignable
{
if (args.NewValue.HasFlag (HighlightStyle.Hover))
{
- SetFocus ();
- return true;
+ //SetFocus ();
+ //return true;
}
- return false;
+ return base.OnHighlight(args);
}
///
@@ -494,9 +494,19 @@ public class Shortcut : View, IOrientation, IDesignable
CommandView.TextFormatter.WordWrap = false;
//CommandView.HighlightStyle = HighlightStyle.None;
CommandView.GettingNormalColor += CommanandView_GettingNormalColor;
+ CommandView.GettingHotNormalColor += CommandViewOnGettingHotNormalColor;
}
+ private void CommandViewOnGettingHotNormalColor (object? sender, CancelEventArgs e)
+ {
+ if (HasFocus)
+ {
+ e.Cancel = true;
+ e.NewValue = GetHotFocusColor ();
+ }
+ }
+
private void CommanandView_GettingNormalColor (object? sender, CancelEventArgs? e)
{
if (HasFocus)
@@ -802,7 +812,6 @@ public class Shortcut : View, IOrientation, IDesignable
public override Attribute GetNormalColor ()
{
if (HasFocus)
-
{
return base.GetFocusColor ();
}
diff --git a/Terminal.Gui/Views/StatusBar.cs b/Terminal.Gui/Views/StatusBar.cs
index 57743989f..3baf415e1 100644
--- a/Terminal.Gui/Views/StatusBar.cs
+++ b/Terminal.Gui/Views/StatusBar.cs
@@ -24,7 +24,7 @@ public class StatusBar : Bar, IDesignable
Width = Dim.Fill ();
Height = Dim.Auto (DimAutoStyle.Content, 1);
BorderStyle = LineStyle.Dashed;
- ColorScheme = Colors.ColorSchemes ["Menu"];
+ base.ColorScheme = Colors.ColorSchemes ["Menu"];
SubViewLayout += StatusBar_LayoutStarted;
}