Currently, InputField will conditionally permit any input changes using the user-provided callback accept(), but only if the input is a regular character (i.e. event.Key() == tcell.KeyRune). This means the callback cannot be used to conditionally permit control characters like backspace.
A simple example is the callback function that renders an InputField read-only:
rejectInput := func(string, rune) bool { return false }
form := tview.NewForm()
form.AddInputField("foo", "bar", 0, rejectInput, nil)
This will prevent new characters from being inserted, but it won't prevent characters from being deleted. In fact, I don't think there exists a way to prevent the user from deleting text in an InputField (I could be wrong on this point).
The same loophole exists for the key-combos Ctrl+U and Ctrl+W.
Currently,
InputFieldwill conditionally permit any input changes using the user-provided callbackaccept(), but only if the input is a regular character (i.e.event.Key() == tcell.KeyRune). This means the callback cannot be used to conditionally permit control characters like backspace.A simple example is the callback function that renders an
InputFieldread-only:This will prevent new characters from being inserted, but it won't prevent characters from being deleted. In fact, I don't think there exists a way to prevent the user from deleting text in an
InputField(I could be wrong on this point).The same loophole exists for the key-combos Ctrl+U and Ctrl+W.