diff --git a/Terminal.Gui/Core/PosDim.cs b/Terminal.Gui/Core/PosDim.cs
index efacd12c8..59ca006f1 100644
--- a/Terminal.Gui/Core/PosDim.cs
+++ b/Terminal.Gui/Core/PosDim.cs
@@ -499,7 +499,7 @@ namespace Terminal.Gui {
return new DimAbsolute (n);
}
- class DimCombine : Dim {
+ internal class DimCombine : Dim {
Dim left, right;
bool add;
public DimCombine (bool add, Dim left, Dim right)
diff --git a/Terminal.Gui/Core/TextFormatter.cs b/Terminal.Gui/Core/TextFormatter.cs
index 84625e2b3..f2e3ba4b8 100644
--- a/Terminal.Gui/Core/TextFormatter.cs
+++ b/Terminal.Gui/Core/TextFormatter.cs
@@ -102,6 +102,11 @@ namespace Terminal.Gui {
/// HotKeyTagMask
public uint HotKeyTagMask { get; set; } = 0x100000;
+ ///
+ /// Gets the cursor position from . If the is defined, the cursor will be positioned over it.
+ ///
+ public int CursorPosition { get; set; }
+
///
/// Gets the formatted lines.
///
@@ -567,16 +572,17 @@ namespace Terminal.Gui {
int x;
switch (textAlignment) {
case TextAlignment.Left:
- x = bounds.Left;
- break;
case TextAlignment.Justified:
x = bounds.Left;
+ CursorPosition = hotKeyPos;
break;
case TextAlignment.Right:
x = bounds.Right - runes.Length;
+ CursorPosition = bounds.Width - runes.Length + hotKeyPos;
break;
case TextAlignment.Centered:
x = bounds.Left + (bounds.Width - runes.Length) / 2;
+ CursorPosition = (bounds.Width - runes.Length) / 2 + hotKeyPos;
break;
default:
throw new ArgumentOutOfRangeException ();
@@ -588,6 +594,9 @@ namespace Terminal.Gui {
rune = runes [col - x];
}
if ((rune & HotKeyTagMask) == HotKeyTagMask) {
+ if (textAlignment == TextAlignment.Justified) {
+ CursorPosition = col - bounds.Left;
+ }
Application.Driver?.SetAttribute (hotColor);
Application.Driver?.AddRune ((Rune)((uint)rune & ~HotKeyTagMask));
Application.Driver?.SetAttribute (normalColor);
diff --git a/Terminal.Gui/Core/View.cs b/Terminal.Gui/Core/View.cs
index fd17902a3..617a7b7d9 100644
--- a/Terminal.Gui/Core/View.cs
+++ b/Terminal.Gui/Core/View.cs
@@ -1086,7 +1086,7 @@ namespace Terminal.Gui {
focused.PositionCursor ();
} else {
if (CanFocus && HasFocus && Visible) {
- Move (textFormatter.HotKeyPos == -1 ? 0 : textFormatter.HotKeyPos, 0);
+ Move (textFormatter.HotKeyPos == -1 ? 0 : textFormatter.CursorPosition, 0);
} else {
Move (frame.X, frame.Y);
}
diff --git a/Terminal.Gui/Views/Button.cs b/Terminal.Gui/Views/Button.cs
index 9492ae68e..73beba18d 100644
--- a/Terminal.Gui/Views/Button.cs
+++ b/Terminal.Gui/Views/Button.cs
@@ -145,7 +145,10 @@ namespace Terminal.Gui {
base.Text = ustring.Make (_leftBracket) + " " + text + " " + ustring.Make (_rightBracket);
int w = base.Text.RuneCount - (base.Text.Contains (HotKeySpecifier) ? 1 : 0);
- Width = w;
+ if (Width is Dim.DimCombine) {
+ // It's a Dim.DimCombine and so can't be assigned. Let it have it's own anchor.
+ w = Width.Anchor (w);
+ }
Height = 1;
Frame = new Rect (Frame.Location, new Size (w, 1));
SetNeedsDisplay ();
diff --git a/Terminal.Gui/Views/RadioGroup.cs b/Terminal.Gui/Views/RadioGroup.cs
index 8e896f1ae..40e2b417a 100644
--- a/Terminal.Gui/Views/RadioGroup.cs
+++ b/Terminal.Gui/Views/RadioGroup.cs
@@ -259,6 +259,14 @@ namespace Terminal.Gui {
}
}
+ ///
+ /// Allow to invoke the after their creation.
+ ///
+ public void Refresh ()
+ {
+ OnSelectedItemChanged (selected, -1);
+ }
+
///
/// Called whenever the current selected item changes. Invokes the event.
///
diff --git a/UICatalog/Scenarios/Buttons.cs b/UICatalog/Scenarios/Buttons.cs
index 43974d741..e0a5d120d 100644
--- a/UICatalog/Scenarios/Buttons.cs
+++ b/UICatalog/Scenarios/Buttons.cs
@@ -266,6 +266,8 @@ namespace UICatalog {
break;
}
};
+
+ Top.Ready += () => radioGroup.Refresh ();
}
}
}
\ No newline at end of file