public TextField(Control parent) : base(parent) { textInput = new TextInput(); textInput.EnterPressed += (txt) => { EnterPressed?.Invoke(this, txt); }; textInput.TextChanged += (txt) => { TextChanged?.Invoke(this, txt); }; textInput.TextTyped += (txt) => { TextTyped?.Invoke(this, txt); }; TextColor = Color.Black; Font = Font.Arial11; }
public void Add(TextInputEventArgs e) { textInputEventArgs.Add(e); if (e.Character != 13 && e.Character != 8 && e.Character >= 1 && e.Character <= 31) { return; } switch (e.Character) { case '\b': //DEL if (TypedText.Length > 0) { TypedText = TypedText.Remove(TypedText.Length - 1); } break; case '\t': //TAB int c = TypedText.Length % 4; TypedText += new string(' ', 4 - c); break; case '\r': //ENTER EnterPressed?.Invoke(TypedText); break; case '\u007f': //CTRL+DEL if (TypedText.Length > 0) { TypedText = TypedText.Remove(Math.Max(TypedText.LastIndexOf(' '), 0)); } break; default: TypedText += e.Character; break; } TextChanged?.Invoke(TypedText); TextTyped?.Invoke(TypedText); }