Fixed Button.NumericUpDown focus issue

This commit is contained in:
Tig
2024-04-14 21:21:44 -06:00
parent 085fd6316d
commit 012e7a376a

View File

@@ -339,7 +339,7 @@ public class Buttons : Scenario
{ {
X = 0, X = 0,
Y = Pos.Bottom (moveUnicodeHotKeyBtn) + 1, Y = Pos.Bottom (moveUnicodeHotKeyBtn) + 1,
Title = "_Numeric Up/Down (press-and-hold):" Title = "_Numeric Up/Down (press-and-hold):",
}; };
var numericUpDown = new NumericUpDown<int> var numericUpDown = new NumericUpDown<int>
@@ -417,7 +417,7 @@ public class Buttons : Scenario
{ {
private readonly Button _down; private readonly Button _down;
// TODO: Use a TextField instead of a Label // TODO: Use a TextField instead of a Label
private readonly Label _number; private readonly View _number;
private readonly Button _up; private readonly Button _up;
public NumericUpDown () public NumericUpDown ()
@@ -432,18 +432,16 @@ public class Buttons : Scenario
Height = 1; Height = 1;
Width = Dim.Function (() => Digits + 2); // button + 3 for number + button Width = Dim.Function (() => Digits + 2); // button + 3 for number + button
CanFocus = true;
_down = new () _down = new ()
{ {
CanFocus = false,
AutoSize = false, AutoSize = false,
Height = 1, Height = 1,
Width = 1, Width = 1,
NoPadding = true, NoPadding = true,
NoDecorations = true, NoDecorations = true,
Title = $"{CM.Glyphs.DownArrow}", Title = $"{CM.Glyphs.DownArrow}",
WantContinuousButtonPressed = true WantContinuousButtonPressed = true,
CanFocus = false,
}; };
_number = new () _number = new ()
@@ -460,7 +458,6 @@ public class Buttons : Scenario
_up = new () _up = new ()
{ {
CanFocus = false,
AutoSize = false, AutoSize = false,
X = Pos.AnchorEnd (1), X = Pos.AnchorEnd (1),
Y = Pos.Top (_number), Y = Pos.Top (_number),
@@ -469,9 +466,12 @@ public class Buttons : Scenario
NoPadding = true, NoPadding = true,
NoDecorations = true, NoDecorations = true,
Title = $"{CM.Glyphs.UpArrow}", Title = $"{CM.Glyphs.UpArrow}",
WantContinuousButtonPressed = true WantContinuousButtonPressed = true,
CanFocus = false,
}; };
CanFocus = true;
_down.Accept += OnDownButtonOnAccept; _down.Accept += OnDownButtonOnAccept;
_up.Accept += OnUpButtonOnAccept; _up.Accept += OnUpButtonOnAccept;
@@ -507,7 +507,11 @@ public class Buttons : Scenario
{ {
InvokeCommand (Command.ScrollUp); InvokeCommand (Command.ScrollUp);
} }
}
private void _up_Enter (object sender, FocusEventArgs e)
{
throw new NotImplementedException ();
} }
private T _value; private T _value;
@@ -556,8 +560,6 @@ public class Buttons : Scenario
/// The number of digits to display. The <see cref="View.Viewport"/> will be resized to fit this number of characters plus the buttons. The default is 3. /// The number of digits to display. The <see cref="View.Viewport"/> will be resized to fit this number of characters plus the buttons. The default is 3.
/// </summary> /// </summary>
public int Digits { get; set; } = 3; public int Digits { get; set; } = 3;
} }
} }