|
@@ -951,6 +951,10 @@ namespace Terminal.Gui {
|
|
|
view.tabIndex = tabIndexes.IndexOf (view);
|
|
|
addingView = false;
|
|
|
}
|
|
|
+ if (view.Enabled && !Enabled) {
|
|
|
+ view.oldEnabled = true;
|
|
|
+ view.Enabled = false;
|
|
|
+ }
|
|
|
SetNeedsLayout ();
|
|
|
SetNeedsDisplay ();
|
|
|
OnAdded (view);
|
|
@@ -1303,14 +1307,16 @@ namespace Terminal.Gui {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (focused?.Visible == true && focused?.Enabled == true && focused?.Frame.Width > 0 && focused.Frame.Height > 0) {
|
|
|
+ if (focused == null && SuperView != null) {
|
|
|
+ SuperView.EnsureFocus ();
|
|
|
+ } else if (focused?.Visible == true && focused?.Enabled == true && focused?.Frame.Width > 0 && focused.Frame.Height > 0) {
|
|
|
focused.PositionCursor ();
|
|
|
+ } else if (focused?.Visible == true && focused?.Enabled == false) {
|
|
|
+ focused = null;
|
|
|
+ } else if (CanFocus && HasFocus && Visible && Frame.Width > 0 && Frame.Height > 0) {
|
|
|
+ Move (TextFormatter.HotKeyPos == -1 ? 0 : TextFormatter.CursorPosition, 0);
|
|
|
} else {
|
|
|
- if (CanFocus && HasFocus && Visible && Frame.Width > 0 && Frame.Height > 0) {
|
|
|
- Move (TextFormatter.HotKeyPos == -1 ? 0 : TextFormatter.CursorPosition, 0);
|
|
|
- } else {
|
|
|
- Move (frame.X, frame.Y);
|
|
|
- }
|
|
|
+ Move (frame.X, frame.Y);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1504,7 +1510,7 @@ namespace Terminal.Gui {
|
|
|
var clipRect = new Rect (Point.Empty, frame.Size);
|
|
|
|
|
|
if (ColorScheme != null) {
|
|
|
- Driver.SetAttribute (HasFocus ? ColorScheme.Focus : ColorScheme.Normal);
|
|
|
+ Driver.SetAttribute (HasFocus ? GetFocusColor () : GetNormalColor ());
|
|
|
}
|
|
|
|
|
|
var boundsAdjustedForBorder = Bounds;
|
|
@@ -1512,7 +1518,7 @@ namespace Terminal.Gui {
|
|
|
Border.DrawContent (this);
|
|
|
boundsAdjustedForBorder = new Rect (bounds.X + 1, bounds.Y + 1, Math.Max (0, bounds.Width - 2), Math.Max(0, bounds.Height - 2));
|
|
|
} else if (ustring.IsNullOrEmpty (TextFormatter.Text) &&
|
|
|
- (GetType ().IsNestedPublic) && !IsOverridden (this, "Redraw") &&
|
|
|
+ (GetType ().IsNestedPublic && !IsOverridden (this, "Redraw") || GetType ().Name == "View") &&
|
|
|
(!NeedDisplay.IsEmpty || ChildNeedsDisplay || LayoutNeeded)) {
|
|
|
|
|
|
Clear ();
|
|
@@ -2619,7 +2625,13 @@ namespace Terminal.Gui {
|
|
|
get => base.Enabled;
|
|
|
set {
|
|
|
if (base.Enabled != value) {
|
|
|
- base.Enabled = value;
|
|
|
+ if (value) {
|
|
|
+ if (SuperView == null || SuperView?.Enabled == true) {
|
|
|
+ base.Enabled = value;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ base.Enabled = value;
|
|
|
+ }
|
|
|
if (!value && HasFocus) {
|
|
|
SetHasFocus (false, this);
|
|
|
}
|
|
@@ -2686,7 +2698,7 @@ namespace Terminal.Gui {
|
|
|
/// to draw the view's border. If <see langword="true"/> no border is drawn (and the view is expected to draw the border
|
|
|
/// itself).
|
|
|
/// </summary>
|
|
|
- public virtual bool IgnoreBorderPropertyOnRedraw { get; set; } = false;
|
|
|
+ public virtual bool IgnoreBorderPropertyOnRedraw { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
/// Pretty prints the View
|
|
@@ -3111,6 +3123,17 @@ namespace Terminal.Gui {
|
|
|
return Enabled ? ColorScheme.Normal : ColorScheme.Disabled;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Determines the current <see cref="ColorScheme"/> based on the <see cref="Enabled"/> value.
|
|
|
+ /// </summary>
|
|
|
+ /// <returns><see cref="Terminal.Gui.ColorScheme.Focus"/> if <see cref="Enabled"/> is <see langword="true"/>
|
|
|
+ /// or <see cref="Terminal.Gui.ColorScheme.Disabled"/> if <see cref="Enabled"/> is <see langword="false"/>.
|
|
|
+ /// If it's overridden can return other values.</returns>
|
|
|
+ public virtual Attribute GetFocusColor ()
|
|
|
+ {
|
|
|
+ return Enabled ? ColorScheme.Focus : ColorScheme.Disabled;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Determines the current <see cref="ColorScheme"/> based on the <see cref="Enabled"/> value.
|
|
|
/// </summary>
|