30 lines
566 B
C#
30 lines
566 B
C#
using Godot;
|
|
using System;
|
|
using BITKit;
|
|
|
|
namespace BITFactory;
|
|
|
|
public partial class UXLineEdit : LineEdit
|
|
{
|
|
[Export] private TextValidationResource textValidation;
|
|
[Export] private RichTextLabel hints;
|
|
|
|
public override void _Ready()
|
|
{
|
|
TextChanged += OnTextChanged;
|
|
}
|
|
|
|
private void OnTextChanged(string newText)
|
|
{
|
|
if (hints is null) return;
|
|
if (textValidation is not null && textValidation.IsTextValid(newText,out var errorReason) is false)
|
|
{
|
|
hints.Text = $"[color=red]{errorReason}[/color]";
|
|
}
|
|
else
|
|
{
|
|
hints.Text = string.Empty;
|
|
}
|
|
}
|
|
}
|