Improvements to hand labeler UI (#31833)

Give line edit focus when window is opened
No longer require pressing enter to set the text
Give feedback when user hits the maximum label length

Co-authored-by: Eoin Mcloughlin <helloworld@eoinrul.es>
This commit is contained in:
eoineoineoin
2024-09-04 15:20:00 +01:00
committed by GitHub
parent fce7abb88e
commit 7fd92abeeb
2 changed files with 15 additions and 1 deletions

View File

@@ -21,7 +21,7 @@ namespace Content.Client.Labels.UI
{
RobustXamlLoader.Load(this);
LabelLineEdit.OnTextEntered += e =>
LabelLineEdit.OnTextChanged += e =>
{
_label = e.Text;
OnLabelChanged?.Invoke(_label);
@@ -33,6 +33,10 @@ namespace Content.Client.Labels.UI
_focused = false;
LabelLineEdit.Text = _label;
};
// Give the editor keybard focus, since that's the only
// thing the user will want to be doing with this UI
LabelLineEdit.GrabKeyboardFocus();
}
public void SetCurrentLabel(string label)
@@ -44,5 +48,10 @@ namespace Content.Client.Labels.UI
if (!_focused)
LabelLineEdit.Text = label;
}
public void SetMaxLabelLength(int maxLength)
{
LabelLineEdit.IsValid = s => s.Length <= maxLength;
}
}
}