Skip to content

Commit

Permalink
Fixes #3655 - Fixes rendering issue in Dialog/MessageBox (#3656)
Browse files Browse the repository at this point in the history
* Fixed rendering issue

* Removed dead code

* Removed dead code
  • Loading branch information
tig authored Aug 10, 2024
1 parent 63e75b7 commit 1f310fd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
23 changes: 16 additions & 7 deletions Terminal.Gui/Views/Dialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,22 @@ public Dialog ()
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>
Expand Down Expand Up @@ -166,12 +182,5 @@ public void AddButton (Button button)

_buttons.Add (button);
Add (button);

SetNeedsDisplay ();

if (IsInitialized)
{
LayoutSubviews ();
}
}
}
10 changes: 0 additions & 10 deletions Terminal.Gui/Views/MessageBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,6 @@ params string [] buttons
d.TextFormatter.WordWrap = wrapMessage;
d.TextFormatter.MultiLine = !wrapMessage;

d.ColorScheme = new ColorScheme (d.ColorScheme)
{
Focus = d.ColorScheme.Normal
};

// Setup actions
Clicked = -1;

Expand All @@ -418,11 +413,6 @@ params string [] buttons
Clicked = buttonId;
Application.RequestStop ();
};

if (b.IsDefault)
{
b.SetFocus ();
}
}

// Run the modal; do not shut down the mainloop driver when done
Expand Down
1 change: 1 addition & 0 deletions UICatalog/Scenarios/Dialogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ Label buttonPressedLabel
dialog = new ()
{
Title = titleEdit.Text,
Text = "Dialog Text",
ButtonAlignment = (Alignment)Enum.Parse (typeof (Alignment), alignmentRadioGroup.RadioLabels [alignmentRadioGroup.SelectedItem]),

Buttons = buttons.ToArray ()
Expand Down

0 comments on commit 1f310fd

Please sign in to comment.