29 lines
537 B
C#
29 lines
537 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 (textValidation is not null && textValidation.IsTextValid(newText,out var errorReason) is false)
|
||
|
{
|
||
|
hints.Text = $"[color=red]{errorReason}[/color]";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
hints.Text = string.Empty;
|
||
|
}
|
||
|
}
|
||
|
}
|