From 1f310fdb74f17704c90f68fecb16d70d382e8d11 Mon Sep 17 00:00:00 2001 From: Tig Date: Sat, 10 Aug 2024 13:03:15 -0600 Subject: [PATCH] Fixes #3655 - Fixes rendering issue in `Dialog`/`MessageBox` (#3656) * Fixed rendering issue * Removed dead code * Removed dead code --- Terminal.Gui/Views/Dialog.cs | 23 ++++++++++++++++------- Terminal.Gui/Views/MessageBox.cs | 10 ---------- UICatalog/Scenarios/Dialogs.cs | 1 + 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Terminal.Gui/Views/Dialog.cs b/Terminal.Gui/Views/Dialog.cs index aefc6eb5a..d6626659d 100644 --- a/Terminal.Gui/Views/Dialog.cs +++ b/Terminal.Gui/Views/Dialog.cs @@ -93,6 +93,22 @@ public class Dialog : Window KeyBindings.Add (Key.Esc, Command.QuitToplevel); } + // BUGBUG: We override GetNormal/FocusColor because "Dialog" ColorScheme is goofy. + // BUGBUG: By defn, a Dialog is Modal, and thus HasFocus is always true. OnDrawContent + // BUGBUG: Calls these methods. + // TODO: Fix this in https://github.com/gui-cs/Terminal.Gui/issues/2381 + /// + public override Attribute GetNormalColor () + { + return ColorScheme.Normal; + } + + /// + public override Attribute GetFocusColor () + { + return ColorScheme.Normal; + } + private bool _canceled; /// Gets a value indicating whether the was canceled. @@ -166,12 +182,5 @@ public class Dialog : Window _buttons.Add (button); Add (button); - - SetNeedsDisplay (); - - if (IsInitialized) - { - LayoutSubviews (); - } } } diff --git a/Terminal.Gui/Views/MessageBox.cs b/Terminal.Gui/Views/MessageBox.cs index 538427909..0fbb09e7a 100644 --- a/Terminal.Gui/Views/MessageBox.cs +++ b/Terminal.Gui/Views/MessageBox.cs @@ -400,11 +400,6 @@ public static class MessageBox d.TextFormatter.WordWrap = wrapMessage; d.TextFormatter.MultiLine = !wrapMessage; - d.ColorScheme = new ColorScheme (d.ColorScheme) - { - Focus = d.ColorScheme.Normal - }; - // Setup actions Clicked = -1; @@ -418,11 +413,6 @@ public static class MessageBox Clicked = buttonId; Application.RequestStop (); }; - - if (b.IsDefault) - { - b.SetFocus (); - } } // Run the modal; do not shut down the mainloop driver when done diff --git a/UICatalog/Scenarios/Dialogs.cs b/UICatalog/Scenarios/Dialogs.cs index cba52dbb1..ded47a5fa 100644 --- a/UICatalog/Scenarios/Dialogs.cs +++ b/UICatalog/Scenarios/Dialogs.cs @@ -263,6 +263,7 @@ public class Dialogs : Scenario dialog = new () { Title = titleEdit.Text, + Text = "Dialog Text", ButtonAlignment = (Alignment)Enum.Parse (typeof (Alignment), alignmentRadioGroup.RadioLabels [alignmentRadioGroup.SelectedItem]), Buttons = buttons.ToArray ()