mirror of
https://github.com/rivo/tview.git
synced 2026-04-27 05:45:49 +03:00
[PR #301] Added FormItem Validation #903
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#903
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?
📋 Pull Request Information
Original PR: https://github.com/rivo/tview/pull/301
Author: @mikeschinkel
Created: 6/10/2019
Status: 🔄 Open
Base:
master← Head:form_validation📝 Commits (2)
06a95afAdd feature-complete FormItemArgs for testing733e087Add FormItem field validation📊 Changes
9 files changed (+679 additions, -5 deletions)
View changed files
📝
application.go(+54 -0)📝
box.go(+13 -0)📝
checkbox.go(+113 -0)📝
dropdown.go(+121 -0)📝
form.go(+69 -5)➕
formitemargs.go(+48 -0)📝
inputfield.go(+142 -0)➕
passwordfield.go(+112 -0)➕
validation.go(+7 -0)📄 Description
This PR includes the commits for #300 because it is too hard to use without the
FormItemArgs(IMO.)This adds a
.validproperty and a.SetValidateFuncto each ofInputField,PasswordField,DropDownandCheckboxstructs.It also adds a
ValidatePrimitive(Primitive,EventKey)method toApplicationand calls that method inside<application>.Run()just before invoking the primitive'sInputHandler().It will only call the validation callback when
event.Key()is one oftcell.KeyEnter,tcell.KeyTab,tcell.KeyBacktabortcell.KeyEscape.If the callback returns
false, it bypasses the input handler and keeps focus on the just now invalidated field.Please consider accepting this update.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.