mirror of
https://github.com/rivo/tview.git
synced 2026-04-27 05:45:49 +03:00
[GH-ISSUE #931] how can I can use color or style to warn that input is invalid #680
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#680
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @stalwartgiraffe on GitHub (Dec 30, 2023).
Original GitHub issue: https://github.com/rivo/tview/issues/931
The Form InputField has an Acceptance Function where if the input string is invalid the accept handler can returns false and the users key press is ignored.
Rather than ignoring a key press, I would rather allow the input text to be incorrect but give the user a visual indicator that the input string is considered invalid. For example, turn the input text field red to signal an error.
But I am not seeing the expected color change when I try to set the field color update in the event handler...
@stalwartgiraffe commented on GitHub (Dec 30, 2023):
Ah. I based my initial code on the basic Form demo, but the AddFormItem documentation at
https://pkg.go.dev/github.com/rivo/tview#Form
says
" Note, however, that the Form class will override some of its attributes to make it work in the form context."
So ok... making custom items style in this manner appears unsupported with the default Form.
ok I guess the new question is there a good tutorial on making a custom form with custom items? How much work is it to do that?
@stalwartgiraffe commented on GitHub (Jan 1, 2024):
I see. SetAttributes is called from the Form Draw() loop, which iterates the collection of items and buttons doing layout and then draws each one.
Thank you
@stalwartgiraffe commented on GitHub (Jan 2, 2024):
Ok Thank you