Bladeren bron

Fixes #3655 - Fixes rendering issue in `Dialog`/`MessageBox` (#3656)

* Fixed rendering issue

* Removed dead code

* Removed dead code
Tig 11 maanden geleden
bovenliggende
commit
1f310fdb74
3 gewijzigde bestanden met toevoegingen van 17 en 17 verwijderingen
  1. 16 7
      Terminal.Gui/Views/Dialog.cs
  2. 0 10
      Terminal.Gui/Views/MessageBox.cs
  3. 1 0
      UICatalog/Scenarios/Dialogs.cs

+ 16 - 7
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
+    /// <inheritdoc />
+    public override Attribute GetNormalColor ()
+    {
+        return ColorScheme.Normal;
+    }
+
+    /// <inheritdoc />
+    public override Attribute GetFocusColor ()
+    {
+        return ColorScheme.Normal;
+    }
+
     private bool _canceled;
 
     /// <summary>Gets a value indicating whether the <see cref="Dialog"/> was canceled.</summary>
@@ -166,12 +182,5 @@ public class Dialog : Window
 
         _buttons.Add (button);
         Add (button);
-
-        SetNeedsDisplay ();
-
-        if (IsInitialized)
-        {
-            LayoutSubviews ();
-        }
     }
 }

+ 0 - 10
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

+ 1 - 0
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 ()