Removing duplicate code.

This commit is contained in:
BDisp
2022-07-02 01:55:11 +01:00
committed by Tig Kindel
parent e02df8c043
commit 6542e86979
3 changed files with 4 additions and 32 deletions

View File

@@ -189,7 +189,9 @@ namespace Terminal.Gui {
public virtual Key HotKey {
get => hotKey;
set {
hotKey = TextFormatter.HotKey = value;
if (hotKey != value) {
hotKey = TextFormatter.HotKey = (value == Key.Unknown ? Key.Null : value);
}
}
}

View File

@@ -37,7 +37,6 @@ namespace Terminal.Gui {
Rune _leftDefault;
Rune _rightDefault;
Key hotKey = Key.Null;
Rune hotKeySpecifier;
/// <summary>
/// Initializes a new instance of <see cref="Button"/> using <see cref="LayoutStyle.Computed"/> layout.
@@ -155,19 +154,11 @@ namespace Terminal.Gui {
} else if (v != Key.Null) {
AddKeyBinding (Key.Space | v, Command.Accept);
}
hotKey = v;
hotKey = TextFormatter.HotKey = v;
}
}
}
/// <inheritdoc/>
public override Rune HotKeySpecifier {
get => hotKeySpecifier;
set {
hotKeySpecifier = TextFormatter.HotKeySpecifier = value;
}
}
/// <inheritdoc/>
protected override void UpdateTextFormatterText ()
{

View File

@@ -13,8 +13,6 @@ namespace Terminal.Gui {
/// The <see cref="CheckBox"/> <see cref="View"/> shows an on/off toggle that the user can set
/// </summary>
public class CheckBox : View {
Key hotKey = Key.Null;
Rune hotKeySpecifier;
Rune charChecked;
Rune charUnChecked;
bool @checked;
@@ -118,25 +116,6 @@ namespace Terminal.Gui {
return Text.RuneSubstring (0, Math.Min (Frame.Width - 2, Text.RuneCount));
}
/// <inheritdoc/>
public override Key HotKey {
get => hotKey;
set {
if (hotKey != value) {
var v = value == Key.Unknown ? Key.Null : value;
hotKey = v;
}
}
}
/// <inheritdoc/>
public override Rune HotKeySpecifier {
get => hotKeySpecifier;
set {
hotKeySpecifier = TextFormatter.HotKeySpecifier = value;
}
}
/// <summary>
/// The state of the <see cref="CheckBox"/>
/// </summary>